One more keyboard backlight script...

This commit is contained in:
Doncho Gunchev 2015-10-21 22:27:58 +03:00
parent 484ba7ddc0
commit a79c6fce59

29
keyboard_backlight.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
cur=$(dbus-send --print-reply=literal --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.GetBrightness | sed s/...int32.//g)
max=$(dbus-send --print-reply=literal --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.GetMaxBrightness | sed s/...int32.//g)
if test -z "$1"; then
echo "$0: Keyboard backlight: $cur / $max"
exit 0
fi
case "$1" in
incr)
val=$(($cur + 1))
lim=$(($val <= $max))
;;
decr)
val=$(($cur - 1))
lim=$(($val >= 0))
;;
*)
val=$1
lim=$(($val >= 0))
;;
esac
if (( "$lim" > 0 )); then
echo "Setting Brightness to $val"
dbus-send --print-reply=literal --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:$val
fi