First commit.

master
Pitriss 7 years ago
parent a1e91c9334
commit eedc8201c2

@ -1,3 +1,7 @@
# G710_backlight # G710 backlight
Bash script that is checking status of DPMS of screen and turns on/off backlight of the keyboard. Bash script that is checking status of DPMS of screen and turns on/off backlight of the keyboard.
Script runs in a loop and chekcks some aspects of system (in this case if smplayer is running in window or fullscreen) and reacts appropriatelly.
I decided to create repo for it, because it can help somebody to achieve simmilar results.

@ -0,0 +1,53 @@
#!/bin/bash
name=$(basename "$0")
me="[${name:0:1}]${name:1}"
run=$(ps -ef | grep "$me" -c)
function checkstatus {
smpfs="nope"
while IFS= read -r line; do
if [ "$(xprop -id $line | grep "_NET_WM_STATE(ATOM)" | grep -c "_NET_WM_STATE_FULLSCREEN")" -eq 1 ]; then
smpfs="yep"
break
fi
done <<< "$(wmctrl -lp | grep SMPlayer | cut -d " " -f1 | tr ' ' '\n')"
echo $smpfs
}
if [ "$run" -ge 3 ]; then
# already running
exit 1
fi
cmd=/usr/local/bin/g710-set-light
delay=5
while [ true ]; do
check=$(xset q | grep Monitor | sed 's/.*Monitor is //' )
if [ "$check" != "$prevstate" ]; then
if [ "$check" = "On" ]; then
prevstate="$check"
$($cmd wasd 3)
$($cmd 1 15)
elif [ "$(wmctrl -lp | grep -c SMPlayer)" -eq 1 ]; then
if [ "$(checkstatus)" = "yep" ]; then
#SMPlayer is in fullscreen mode - turn off backlight
prevstate="Off" # force recheck
$($cmd wasd 4)
$($cmd 1 0)
else
#SMPlayyer is in window mode - keep backlight on
prevstate="On" # Force recheck
$($cmd wasd 3)
$($cmd 1 15)
fi
else
prevstate="$check"
$($cmd wasd 4)
$($cmd 1 0)
fi
fi
sleep $delay
done
Loading…
Cancel
Save