-
Notifications
You must be signed in to change notification settings - Fork 4
/
ledbyscreensaver.sh
executable file
·46 lines (37 loc) · 1.22 KB
/
ledbyscreensaver.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#/bin/bash
# This script will make the LED show open eyes when your computer is active, and
# closed eyes when your screensaver comes on.
# To make it launch on startup, put this command in your startup applications list:
# bash -c "/PATH/TO/YOUR/ledbyscreensaver.sh"
eyes=${1:-kitty}
pathtoeyes="/home/aaronw/programs/pydcled/eyes.py -e $eyes"
# For Mint MATE
screensaverintf="interface=org.mate.ScreenSaver,member=ActiveChanged"
# For Gnome
#screensaverintf="interface=org.gnome.ScreenSaver,member=ActiveChanged"
dbus-monitor --session "$screensaverintf" --monitor | (
echo "Waking up!"
python $pathtoeyes &
LEDPID=$!
function clean_up {
kill $LEDPID
echo "LED is now powered off."
reset
exit
}
trap clean_up SIGTERM SIGINT SIGHUP
while true; do
read X
if echo $X | grep "boolean true" &> /dev/null; then
echo "Going to sleep!"
kill $LEDPID &> /dev/null 2>&1
python $pathtoeyes --shut &
LEDPID=$!
elif echo $X | grep "boolean false" &> /dev/null; then
echo "Waking up!"
kill $LEDPID &> /dev/null 2>&1
python $pathtoeyes &
LEDPID=$!
fi
done
)