-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathilock
executable file
·40 lines (36 loc) · 961 Bytes
/
ilock
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/sh
fetchjoke() {
curl -sH "Accept: text/plain" https://icanhazdadjoke.com/ |
sed 's/\? /\?\n/' | sed 's/\. /\.\n/' >~/.cache/dadjoke
}
if iconf -i dadjoke; then
# fetch random dad joke
if ! [ -e ~/.cache/dadjoke ]; then
fetchjoke
fi
(sleep 2 && fetchjoke &)
MESSAGE="$(cat ~/.cache/dadjoke)"
elif [ "$1" = "message" ]; then
# manual message
MESSAGE="$(imenu -i "enter lock screen message")"
[ -z "$MESSAGE" ] && exit
shift
else
# default
MESSAGE="locked, enter password for $(whoami)"
fi
if [ "$1" = '-o' ] || [ -n "$ILOCKACTIVE" ]; then
if iconf -i nolocktimeout; then
echo "keeping screen active"
instantlock -o -d
else
instantlock -o && xset -dpms
fi
else
if ! iconf -i nolocktimeout; then
instantlock -m "${@:-$MESSAGE}" && xset -dpms
else
echo "keeping screen active"
instantlock -d -m "${@:-$MESSAGE}"
fi
fi