{"id":13793274,"url":"https://github.com/pirate/mac-keyboard-brightness","last_synced_at":"2025-05-12T20:30:53.725Z","repository":{"id":65439460,"uuid":"90349456","full_name":"pirate/mac-keyboard-brightness","owner":"pirate","description":"🔆 Programmatically get \u0026 set the keyboard \u0026 display backlight brightness on Macs. Flash your keyboard to the music! (only works on \u003c2015 Macs)","archived":true,"fork":false,"pushed_at":"2024-02-02T11:06:30.000Z","size":31,"stargazers_count":218,"open_issues_count":1,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-18T08:49:25.862Z","etag":null,"topics":["backlight","brightness","c","keyboard","mac","terminal","utilities"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pirate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-05T07:30:37.000Z","updated_at":"2024-07-11T01:27:04.000Z","dependencies_parsed_at":"2024-08-03T23:01:23.305Z","dependency_job_id":null,"html_url":"https://github.com/pirate/mac-keyboard-brightness","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fmac-keyboard-brightness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fmac-keyboard-brightness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fmac-keyboard-brightness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirate%2Fmac-keyboard-brightness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pirate","download_url":"https://codeload.github.com/pirate/mac-keyboard-brightness/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816669,"owners_count":21968862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backlight","brightness","c","keyboard","mac","terminal","utilities"],"created_at":"2024-08-03T23:00:17.521Z","updated_at":"2025-05-12T20:30:53.397Z","avatar_url":"https://github.com/pirate.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"## Archived: Use https://github.com/EthanRDoesMC/KBPulse for Macs released after 2016\n\n---\n\n# Control Mac Keyboard Brightness: kbrightness \u0026 dbrightness\nProgrammatically flash the keyboard lights and control display brightness on Macs.  You can flash them to the beat of music, or use it for alerts and notifications.\n\nThis was inspired by [@tcr's repo](https://github.com/tcr/macbook-brightness).  This is also an alternative to the old iSpazz iTunes plugin, which no longer works.\nI had trouble finding any other easy-to-use binary for controlling keyboard brightness, so I made one.\n\n\n![Flashing keyboard gif](https://i.imgur.com/AS6tTre.gif)\n![Flashing display gif](https://i.imgur.com/cRFsoDM.gif)\n\n## Usage\n\n - `blink` is a shortcut to flash the keyboard lights [n] times for [t] seconds each time\n - `kbrightness` manages the keyboard backlight brightness\n - `dbrightness` manages the display backlight brightness\n - `python3 audio.py` flash the keyboard based on the audio input from your mic, makes it flash to the beat of music\n\nUse blink in your shell scripts to alert you when things have succeeded or failed.\ne.g. `wget https://example.com/large-file.mp4 \u0026\u0026 blink 2` or `./tests.py || blink 3 1`\n\n```bash\ngit clone https://github.com/pirate/mac-keyboard-brightness\ncd mac-keyboard-brightness/\n\n./kbrightness          # gets current keyboard brightness\n# 0.286447\n./kbrightness 0.85     # sets keyboard brightness to 85%\n\n./dbrightness          # gets current display brightness\n# 0.938477\n./dbrightness 0.42     # sets display brightness to 42%\n=======\n\n./blink                # flash the keyboard lights once (good for subtle alerts, e.g. git pull \u0026\u0026 blink 2)\n./blink 2              # flash the keyboard lights twice\n./blink 10 0.1         # flash the keyboard lights 10 times, for 0.1 seconds each time\n./blink 1000 0.01      # turn your keyboard into a disco strobe\n\n=======\n\n# Flash your keyboard to the beat of the music! (uses mic input)\nbrew install python3 pyaudio portaudio\npip3 install --upgrade pyaudio audioop\npython3 audio.py\n```\nYou should be able to download the repo and use the binaries without needing to recompile anything (tested on macOS Sierra, High Sierra, and Mojave).\n\n## Why?\n\nIt's fun.  Here are some ideas:\n\n - make a bitbar menubar app to control keyboard brightness\n - make your keyboard lights flash for security alerts using [Security Growler](https://github.com/pirate/security-growler)\n - make your keyboard flash right before your display is about to sleep\n - make your keyboard flash on incoming email\n - make your keyboard flash to the beat of music\n - make your keyboard flash when your boss's iPhone comes within bluetooth range\n\n## Advanced\n\nIf you want to write more advanced programs to update the brightness at higher frequencies\n(e.g. to make your keyboard flash to music), you can use the C functions directly.\n\n - `setDisplayBrightness`, `getDisplayBrightness`\n - `setKeyboardBrightness`, `getKeyboardBrightness`\n - `getLightSensors`: get ambient light sensor values, see [@tcr's original repo](https://github.com/tcr/macbook-brightness/blob/master/displaybrightness.c#L54)\n\nCompile each file individually with:\n\n```bash\ngcc -std=c99 -o kbrightness keyboard-brightness.c -framework IOKit -framework ApplicationServices\n# OR\ngcc -std=c99 -o dbrightness display-brightness.c -framework IOKit -framework ApplicationServices\n```\n\n## Links\n\n- https://github.com/maxmouchet/LightKit control keyboard and screen brightness via Swift\n- https://github.com/tcr/macbook-brightness (the core brightness code is copied from @tcr's, but separated into two cli utils)\n- http://stackoverflow.com/questions/3239749/programmatically-change-mac-display-brightness\n- https://web.archive.org/web/20110828210316/http://mattdanger.net:80/2008/12/adjust-mac-os-x-display-brightness-from-the-terminal/\n- http://osxbook.com/book/bonus/chapter10/light/\n- https://github.com/samnung/maclight/blob/master/lights_handle.cpp\n- http://www.keindesign.de/stefan/Web/Sites/iWeb/Site/iSpazz.html\n- https://github.com/bhoeting/DiscoKeyboard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirate%2Fmac-keyboard-brightness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpirate%2Fmac-keyboard-brightness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirate%2Fmac-keyboard-brightness/lists"}