Skip to content

Instantly share code, notes, and snippets.

@craigmbooth
Created May 3, 2020 20:25
Show Gist options
  • Select an option

  • Save craigmbooth/47348081f04f36f1fc54bb69a7cc9ad3 to your computer and use it in GitHub Desktop.

Select an option

Save craigmbooth/47348081f04f36f1fc54bb69a7cc9ad3 to your computer and use it in GitHub Desktop.
Toggles the keyboard lights on a Thinkpad
#!/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