Skip to content

Commit 4211581

Browse files
committed
Updates to kbd_brightness to take inputs instead of only relying on the GUI.
1 parent 4f1cba1 commit 4211581

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

bin/kbd_brightness

+29-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
sudo sh -c 'yad --on-top --scale --min-value=0 --max-value=2 --step=1 --enforce-step --print-partial --value=$(cat /sys/class/leds/tpacpi\:\:kbd_backlight/brightness) | while read line; do echo "$line" > /sys/class/leds/tpacpi\:\:kbd_backlight/brightness; sleep 0.01; done'
1+
2+
if [ $# -eq 0 ]; then
3+
# no arguments provided, show gui
4+
sudo sh -c \
5+
'yad --on-top --scale \
6+
--min-value=0 --max-value=2 --step=1 --enforce-step \
7+
--print-partial \
8+
--value=$(cat /sys/class/leds/tpacpi\:\:kbd_backlight/brightness) | \
9+
while read line; do echo "$line" > /sys/class/leds/tpacpi\:\:kbd_backlight/brightness; sleep 0.01; done'
10+
11+
else
12+
# input was provided as either a delta or absvalue
13+
absval=0
14+
curval=$(cat /sys/class/leds/tpacpi\:\:kbd_backlight/brightness)
15+
if [ "${1:0:1}" == "+" ]; then
16+
absval=$(expr $curval + ${1:1})
17+
elif [ "${1:0:1}" == "-" ]; then
18+
absval=$(expr $curval - ${1:1})
19+
else
20+
absval=$1
21+
fi
22+
23+
sudo sh -c "echo $absval > /sys/class/leds/tpacpi\:\:kbd_backlight/brightness" 2> /dev/null
24+
25+
if [ $? -ne 0 ]; then
26+
echo "Invalid input $1"
27+
exit 1
28+
fi
29+
fi

0 commit comments

Comments
 (0)