kb-layout-caps-led/scripts/kb-layout-signal-watcher.sh

28 lines
600 B
Bash
Raw Normal View History

2019-05-04 02:34:41 +03:00
#!/bin/bash
echo $$ > /tmp/kb-layout-signal-watcher.pid
CAPS_INPUT=$(ls /sys/class/leds/ | grep caps | head -n 1)
echo $CAPS_INPUT
2019-05-05 16:53:13 +03:00
LAST_KB_LAYOUT=""
2019-05-04 02:34:41 +03:00
while :
do
CURRENT_KB_LAYOUT=$(cat /tmp/kb-layout)
2019-05-05 16:53:13 +03:00
if ! [[ "$LAST_KB_LAYOUT" == "$CURRENT_KB_LAYOUT" ]]; then
2019-05-04 02:34:41 +03:00
if [[ "$CURRENT_KB_LAYOUT" == "1" ]]; then
2019-05-05 16:53:13 +03:00
#echo 0
2019-05-04 02:34:41 +03:00
echo 0 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
else
2019-05-05 16:53:13 +03:00
#echo 1
2019-05-04 02:34:41 +03:00
echo 1 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
fi
2019-05-05 16:53:13 +03:00
LAST_KB_LAYOUT="$CURRENT_KB_LAYOUT"
2019-05-04 02:34:41 +03:00
fi
sleep .1
done