-
Notifications
You must be signed in to change notification settings - Fork 1
/
asciiquarium-lock.sh
executable file
·38 lines (34 loc) · 1.19 KB
/
asciiquarium-lock.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
#!/bin/bash
# Dependency checks
if [ ! $(command -v asciiquarium) ]; then
echo "\"command not found: \"asciiquarium\"" >&2
exit 1
fi
if [ ! $(command -v xfce4-terminal) ]; then
echo "\"command not found: \"xfce4-terminal\"" >&2
exit 1
fi
if [ ! $(command -v pyxtrlock) ]; then
echo "\"command not found: \"pyxtrlock\"" >&2
exit 1
fi
# Check for xrandr and run xterms
if [ $(command -v xrandr) ]; then
OFFSETS=$(\xrandr | \grep -w connected | \awk '{split($0, line, " "); if (line[3] == "primary") { split(line[4], offsets, "+"); print "+"offsets[2]"+"offsets[3] } else { split(line[3], offsets, "+"); print "+"offsets[2]"+"offsets[3] }}')
for o in $OFFSETS; do
\xfce4-terminal --geometry 0x0$o --fullscreen --hide-menubar --hide-scrollbar --hide-borders -e asciiquarium &
done
else
xterm -fullscreen -e asciiquarium &
fi
# Store the current layout and set the default one
if [ $(command -v xkblayout-state) ]; then
CURRENT=$(xkblayout-state print %c)
xkblayout-state set 0
fi
#Lock screen and kill all the child processes on unlock
pyxtrlock && pkill -P $$
#Restore kb layout
if [ $(command -v xkblayout-state) ]; then
xkblayout-state set $CURRENT
fi