{"id":18649593,"url":"https://github.com/vorpalblade/keyboard-backlightd","last_synced_at":"2025-04-11T14:32:11.016Z","repository":{"id":65973638,"uuid":"598758194","full_name":"VorpalBlade/keyboard-backlightd","owner":"VorpalBlade","description":"Daemon for automatic timeout of laptop (ThinkPad) keyboard backlight","archived":false,"fork":false,"pushed_at":"2025-04-07T11:49:06.000Z","size":271,"stargazers_count":11,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T12:38:01.817Z","etag":null,"topics":["backlight","keyboard","linux"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VorpalBlade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-07T18:50:44.000Z","updated_at":"2025-04-07T11:49:04.000Z","dependencies_parsed_at":"2024-04-22T09:42:15.647Z","dependency_job_id":"ad1c4e15-dd33-494c-bda0-e41b147df15c","html_url":"https://github.com/VorpalBlade/keyboard-backlightd","commit_stats":{"total_commits":40,"total_committers":1,"mean_commits":40.0,"dds":0.0,"last_synced_commit":"cce7eb121acfd937c2c375b6c29ecc7af136d1e9"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VorpalBlade%2Fkeyboard-backlightd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VorpalBlade%2Fkeyboard-backlightd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VorpalBlade%2Fkeyboard-backlightd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VorpalBlade%2Fkeyboard-backlightd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VorpalBlade","download_url":"https://codeload.github.com/VorpalBlade/keyboard-backlightd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248419750,"owners_count":21100244,"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","keyboard","linux"],"created_at":"2024-11-07T06:39:05.072Z","updated_at":"2025-04-11T14:32:06.002Z","avatar_url":"https://github.com/VorpalBlade.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `keyboard-backlightd`\n\n[ [crates.io] ] [ [lib.rs] ] [ [AUR] ]\n\nA daemon to turn off the keyboard backlight when idle.\n\nFeatures:\n\n* Small, minimal dependencies, fast to compile.\n* Supports adjusting the keyboard backlight using the normal key (by\n  monitoring if brightness was changed by hardware and adjusting accordingly).\n\nLimitations:\n\n* Only tested on modern ThinkPads.\n* Very little auto-detection, you will need to configure your input devices\n* Linux only. Uses some *very* low level APIs.\n\n## Installation\n\nWhile this package can be built with `cargo` as most rust packages, it uses\n`make` for installation. This is because `cargo` is not able to install the\nadditional files that are needed: The config file and the systemd unit file.\n\nWhy is this needed? Since this is a system daemon it needs to be installed\nsystem-wide and run as root (to be able to access certain files in `/dev`\nand `/sys`).\n\nThus, you should ideally install this with your distro package manager. A\npackage for Arch Linux is available on [AUR] (maintained by the author of\nthis package).\n\nIf you do not use Arch Linux, I would appreciate if you can contribute\ncreating a package! However, if you do not want to create a package, do\nsomething like this to install into `/usr/local`:\n\n```bash\n# NOTE! Not recommended! This will overwrite your config file for this\n# program, which sucks if you customised it. Use your package manager\n# instead!\nmake\nsudo make install\n```\n\n## Warning!\n\nThis program will monitor your key presses, but only to detect when you press\nthe keys. It does however not care about *what* you press. The only thing the\ncode checks is if it is a LED changing state, in which case it is ignored\n(otherwise, pressing Caps Lock on an external keyboard would light up the\nkeyboard backlight).\n\nIn summary: This code works very similar to how a keylogger would, except that\nit is benign. But you should read the code first to make sure you trust me with\nthis! (This is a good idea in general!)\n\nThe code that does this is in [`handlers.rs`](src/handlers.rs) in the `mod ev_dev` section.\n\n## Figuring out input devices \u0026 LEDs\n\nYou probably want this daemon to turn on the keyboard backlight on any of:\n\n* Keyboard keys\n* Special Fn-key combos?\n* Touchpad\n* Trackpoint\n\nThe easiest way is to run `sudo evtest` (you may need to install a package\nsuch as `evtest`). This will give you an output such as this:\n\n```console\n$ sudo evtest\nNo device specified, trying to scan all of /dev/input/event*\nAvailable devices:\n/dev/input/event0:  Sleep Button\n/dev/input/event1:  Lid Switch\n/dev/input/event10: ThinkPad Extra Buttons\n/dev/input/event11: HDA Intel PCH Mic\n/dev/input/event12: HDA Intel PCH Headphone\n/dev/input/event13: HDA Intel PCH HDMI/DP,pcm=3\n/dev/input/event14: HDA Intel PCH HDMI/DP,pcm=7\n/dev/input/event15: HDA Intel PCH HDMI/DP,pcm=8\n/dev/input/event16: Synaptics TM3276-022\n/dev/input/event17: TPPS/2 IBM TrackPoint\n/dev/input/event18: Integrated Camera: Integrated C\n/dev/input/event19: MX Vertical Mouse\n/dev/input/event2:  Power Button\n/dev/input/event3:  AT Translated Set 2 keyboard\n/dev/input/event4:  Video Bus\n/dev/input/event5:  Video Bus\n/dev/input/event6:  Microsoft Comfort Curve Keyboard 3000\n/dev/input/event7:  Microsoft Comfort Curve Keyboard 3000\n/dev/input/event8:  Raydium Corporation Raydium Touch System\n/dev/input/event9:  PC Speaker\nSelect the device event number [0-19]:\n```\n\nThis lets you identify the input devices Linux sees. However, this is not\nquite what you want, as the numbering is not guaranteed to be stable across\nreboots.\n\nNext you need to find a stable ID for these:\n\n```console\n$ ls -l /dev/input/by-id                                \nlrwxrwxrwx 1 root root  9  7 feb 16.31 usb-Microsoft_Comfort_Curve_Keyboard_3000-event-kbd -\u003e ../event6\nlrwxrwxrwx 1 root root  9  7 feb 16.31 usb-Microsoft_Comfort_Curve_Keyboard_3000-if01-event-kbd -\u003e ../event7\nlrwxrwxrwx 1 root root  9  7 feb 16.31 usb-Raydium_Corporation_Raydium_Touch_System-event-if00 -\u003e ../event8\nlrwxrwxrwx 1 root root 10  7 feb 16.31 usb-SunplusIT_Inc_Integrated_Camera-event-if00 -\u003e ../event18\n$ ls -l /dev/input/by-path\nlrwxrwxrwx 1 root root  9  7 feb 16.31 pci-0000:00:14.0-usb-0:10:1.0-event -\u003e ../event8\nlrwxrwxrwx 1 root root  9  7 feb 16.31 pci-0000:00:14.0-usb-0:1:1.0-event-kbd -\u003e ../event6\nlrwxrwxrwx 1 root root  9  7 feb 16.31 pci-0000:00:14.0-usb-0:1:1.1-event-kbd -\u003e ../event7\nlrwxrwxrwx 1 root root 10  7 feb 16.31 pci-0000:00:14.0-usb-0:8:1.0-event -\u003e ../event18\nlrwxrwxrwx 1 root root 10  7 feb 16.31 pci-0000:00:1f.4-event-mouse -\u003e ../event16\nlrwxrwxrwx 1 root root  9  7 feb 16.31 pci-0000:00:1f.4-mouse -\u003e ../mouse1\nlrwxrwxrwx 1 root root 10  7 feb 16.31 pci-0000:00:1f.4-serio-2-event-mouse -\u003e ../event17\nlrwxrwxrwx 1 root root  9  7 feb 16.31 pci-0000:00:1f.4-serio-2-mouse -\u003e ../mouse2\nlrwxrwxrwx 1 root root  9  7 feb 16.31 platform-i8042-serio-0-event-kbd -\u003e ../event3\nlrwxrwxrwx 1 root root  9  7 feb 16.31 platform-pcspkr-event-spkr -\u003e ../event9\nlrwxrwxrwx 1 root root 10  7 feb 16.31 platform-thinkpad_acpi-event -\u003e ../event10\n```\n\nHere you should prefer a `by-id` mapping if one exists for your device, though\nfor non-USB devices `by-path` will likely work fine.\n\nFrom the output above we can conclude that we want:\n\n| Device          | Human readable name                      | Number | Path we want                                                               |\n|-----------------|------------------------------------------|--------|----------------------------------------------------------------------------|\n| Keyboard        | AT Translated Set 2 keyboard             |      3 | `/dev/input/by-path/platform-i8042-serio-0-event-kbd`                      |\n| Special buttons | ThinkPad Extra Buttons                   |     10 | `/dev/input/by-path/platform-thinkpad_acpi-event`                          |\n| Touchpad        | Synaptics TM3276-022                     |     16 | `/dev/input/by-path/pci-0000:00:1f.4-event-mouse`                          |\n| Trackpoint      | TPPS/2 IBM TrackPoint                    |     17 | `/dev/input/by-path/pci-0000:00:1f.4-serio-2-event-mouse`                  |\n| Touchscreen     | Raydium Corporation Raydium Touch System |      8 | `/dev/input/by-id/usb-Raydium_Corporation_Raydium_Touch_System-event-if00` |\n\nThese are (for this laptop, a ThinkPad T480) all the inputs we want to monitor.\n\nHere are some hints for figuring this out:\n\n* The two most common vendors I have seen for touchpads are Synaptics and ALPS.\n* You can always use evtest to check if key presses go to a specific device.\n\nThus, our command line for `keyboard-backlightd` would look like:\n\n```text\n-i /dev/input/by-path/platform-i8042-serio-0-event-kbd \\\n-i /dev/input/by-path/platform-thinkpad_acpi-event \\\n-i /dev/input/by-path/pci-0000:00:1f.4-event-mouse \\\n-i /dev/input/by-path/pci-0000:00:1f.4-serio-2-event-mouse \\\n-i /dev/input/by-id/usb-Raydium_Corporation_Raydium_Touch_System-event-if00\n```\n\nThen you also need to figure out the path to your LED for keyboard backlight.\nThis is thankfully much easier:\n\n```console\n$ ls -d /sys/class/leds/*kbd*\n/sys/class/leds/tpacpi::kbd_backlight\n```\n\nIn this case there was only one option. This means we want:\n\n```text\n-l /sys/class/leds/tpacpi::kbd_backlight\n```\n\n## Configuration\n\nOnce you have found your required command line parameters, edit\n`/etc/conf.d/keyboard-backlightd` to set them for use in the systemd service.\n\nThen enable and start the systemd service and make sure everything still works:\n```bash\nsystemctl enable keyboard-backlightd\nsystemctl start keyboard-backlightd\n```\n\nIf you have issues with the service not starting during boot, consider\nincreasing `WAIT` in the configuration file. This might help with late loaded\nkernel modules causing the device node to not be available when the daemon\nstarts.\n\n## Troubleshooting\n\n### The keyboard backlight stops turning on if I hit the key that manually controls the backlight\n\nThis is by design. The daemon monitors (on supported laptops) for external\nchanges to the keyboard backlight. That could be other software or the user\npressing some laptop specific key combo (often involving the `Fn` key). On\nmodern Thinkpads (2020-ish) this key combo is `Fn+Space` which cycles\nbetween \"off\", \"half\" and \"bright\".\n\n`keyboard-backlightd` will adapt to what the user sets and toggle between\n\"off\" and whatever brightness level the user just set. If you happen to set\nit to off, that means you will get toggling between \"off\" and \"off\". Just\nhit the key combo again to resume operation at the next level of brightness.\n\nIf you really don't want this, you can use the flag `--no-adaptive-brightness`\nto the daemon. But consider giving it a try first, you might grow to like it.\n\n## Minimum supported rust version (MSRV)\n\nCurrently, at least Rust 1.74.0 is needed, but this may change at any time\nif needed. MSRV change is not considered a breaking change and as such may\nchange even in a patch version.\n\n## License\n\n`keyboard-backlightd` is released under GPL 3.0 (only, not \"or later\").\n\n[AUR]: https://aur.archlinux.org/packages/keyboard-backlightd\n[crates.io]: https://crates.io/crates/keyboard-backlightd\n[lib.rs]: https://lib.rs/crates/keyboard-backlightd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvorpalblade%2Fkeyboard-backlightd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvorpalblade%2Fkeyboard-backlightd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvorpalblade%2Fkeyboard-backlightd/lists"}