Created
May 3, 2020 20:25
-
-
Save craigmbooth/47348081f04f36f1fc54bb69a7cc9ad3 to your computer and use it in GitHub Desktop.
Toggles the keyboard lights on a Thinkpad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script that switches on and off the keyboard light on my Thinkpad | |
| backlight_set() { | |
| value="$1" | |
| dbus-send --type=method_call --print-reply=literal --system \ | |
| --dest='org.freedesktop.UPower' \ | |
| '/org/freedesktop/UPower/KbdBacklight' \ | |
| 'org.freedesktop.UPower.KbdBacklight.SetBrightness' \ | |
| "int32:${value}}" | |
| } | |
| backlight_get() { | |
| cat /sys/class/leds/tpacpi::kbd_backlight/brightness | |
| } | |
| current_backlight=$(backlight_get) | |
| if (( $current_backlight > 0 )); then | |
| backlight_set 0 | |
| else | |
| backlight_set 2 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment