blob: aa8a6b16699e27246aa79647457b0a2827bd88cf (
plain)
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
|
#!/bin/zsh
#set -x
USER="raghavendra"
duration=120
export DISPLAY=:0
state_file="/home/$USER/.dpms/.state"
previous=$(< $state_file)
while :
do
# Heartbeat for flash
#state=$(top -b -n 1 | grep plugin-cont | head -1 | awk '{ print $8 }')
if xdotool search --name '.*flash.*';then
#if [[ -n $state && $state == 'R' ]];then
sudo -u $USER xdotool key ctrl
sleep 10
continue
fi
mplayeraux status
if [[ $? == 1 ]];then
sleep 60
else
inotifywait -t $duration /dev/input/event*
fi
if [[ $? == 2 && $previous == up ]];then
for file in /home/$USER/.dpms/*;do
$file down
done
echo -n "down" >| $state_file
elif [[ $previous == down ]];then
for file in /home/$USER/.dpms/*;do
$file up
done
echo -n "up" >| $state_file
else
sleep 60
#Something else or nothing
fi
done
#set +x
|