-
Notifications
You must be signed in to change notification settings - Fork 1
/
glasses.sh
executable file
·65 lines (54 loc) · 1.3 KB
/
glasses.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#By Adam Hallgat (https://github.com/hallgat89/)
getwid2 ()
{
a=`xdotool getactivewindow` &>/dev/null || :
printf 0x%x $a #convert to wmctrl format
}
set -e
function cleanup {
wmctrl -ir "$WID" -T "$WIT" &>/dev/null
}
trap cleanup EXIT
WID=$(getwid2)
WIT=`xdotool getactivewindow getwindowname` &>/dev/null ||:
CWIT=$WIT #this will store the current window title
state=0 #animation state
while [ "1" -eq "1" ]
do
if [ "$state" -eq "0" ]
then
guy='( •_• )'
elif [ "$state" -eq "1" ]
then
guy='( •_• )>⌐■-■'
elif [ "$state" -eq "2" ]
then
guy='(⌐■_■)'
fi
NWID=$(getwid2)
if [ "$NWID" != "$WID" ]
then
#window changed
state=0
guy='( •_• )'
wmctrl -ir "$WID" -T "$WIT" &>/dev/null || state=0
WID=$(getwid2)
WIT=`xdotool getactivewindow getwindowname`&>/dev/null || state=0
fi
TWIT=`xdotool getactivewindow getwindowname`&>/dev/null || state=0
if [ "$TWIT" != "$CWIT" ]
then
#title changed
WIT=$TWIT
fi
if [ "$state" -lt "3" ]
then
state=$(($state+1))
CWIT="$guy"
else
CWIT="$guy $WIT"
fi
wmctrl -ir "$WID" -T "$CWIT" &>/dev/null || state=0
sleep 1
done