Commit fea180e9 authored by Russell's avatar Russell
Browse files

Turn off the keyboard leds when the lid is closed.

Script to listen to the lid switch then toggle the power to the keyboard leds.
Also the systemd service so it starts on boot.
parent c6da9ca2
[Unit]
Description=Pyra Keyboard Led Daemon
Documentation=https://dev.pyra-handheld.com/packages/pyra-hacks
[Service]
ExecStart=/usr/share/pyra/scripts/pyra-sleepkeyboard.sh daemon
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=pyra-keyboardled.service
#!/bin/bash
EVENT="/dev/input/by-path/platform-pyra-lid-wakeup-event"
LID_CODE=5
LID_VAL_OPEN=0
LID_VAL_CLOSED=1
#Was hoping that the reft/mid/right leds could be turned of the same way but they don't have bl_power
TARGETS=("/sys/bus/platform/devices/keyboard-backlight/backlight/keyboard-backlight/bl_power")
POWER_ON=0
POWER_OFF=4
function lidOpen {
for i in "${TARGETS[@]}"; do
echo "$POWER_ON" > $i
done
}
function lidClosed {
for i in "${TARGETS[@]}"; do
echo "$POWER_OFF" > $i
done
}
cat $EVENT | stdbuf -o L od -An -i | while read time type code val junk; do
if [[ "$code" == "$LID_CODE" ]]; then
if [[ "$val" == "$LID_VAL_OPEN" ]]; then
lidOpen
elif [[ "$val" == "$LID_VAL_CLOSED" ]]; then
lidClosed
fi
fi
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment