-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer-auto-stop.sh
More file actions
executable file
·52 lines (43 loc) · 869 Bytes
/
timer-auto-stop.sh
File metadata and controls
executable file
·52 lines (43 loc) · 869 Bytes
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
46
47
48
49
50
51
52
#!/bin/bash
timer_prog="timer"
xset_prog="xset"
timer_is_start()
{
if [ "$(timer current)" = "NO TASKS" ]; then
echo "off"
else
echo "on"
fi
}
screen_status()
{
local xset_status=$($xset_prog q | grep "Monitor is On")
if [ -z "$xset_status" ]; then
echo "off"
else
echo "on"
fi
}
timer_on=$(timer_is_start)
scr_status=$(screen_status)
while true
do
scr=$(screen_status)
if [ $scr != $scr_status ]; then
case $scr in
on)
if [ $timer_on = "on" ]; then
$timer_prog start
fi
;;
off)
timer_on=$(timer_is_start)
if [ $timer_on = "on" ]; then
$timer_prog stop
fi
;;
esac
fi
scr_status=$scr
sleep 5
done