dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/bin/exeflock4

107 lines
1.8 KiB
Plaintext
Raw Normal View History

2018-08-23 19:00:30 +00:00
#!/usr/bin/env bash
2017-09-04 19:19:36 +00:00
2018-10-18 19:25:56 +00:00
set -euf -o pipefail
pre_lock() {
dunst() {
pkill -0 --exact dunst || return 0
case ${1:-} in
stop)
pkill -USR1 --euid "$(id -u)" --exact dunst
;;
resume)
pkill -USR2 --euid "$(id -u)" --exact dunst
;;
*)
echo "dunst argument required: stop or resume"
return 1
;;
esac
}
dunst stop
2017-09-04 19:19:36 +00:00
}
2018-10-18 19:25:56 +00:00
post_lock() {
dunst resume
}
2017-09-04 19:19:36 +00:00
2018-07-21 04:46:57 +00:00
# lock colors
c0='#00000000' # clear
2018-10-18 19:25:56 +00:00
#c1='#000000ff' # black
2018-08-23 19:00:30 +00:00
c2='#FABD2F88'
c3='#FB493488'
c4='#EBDBB2FF'
c5='#B8BB2688'
2018-08-23 19:00:30 +00:00
c6='#28282888'
c7='#282828FF'
2018-07-21 04:46:57 +00:00
c8='#eeeeecff'
c9='#12121200'
cA='#c4a000ff'
lock="$HOME/Pictures/trilock.png"
2018-08-23 19:00:30 +00:00
image=$(mktemp --suffix=.png)
trap 'rm -f "$image"' SIGINT SIGTERM EXIT
maim -u \
| convert png:- -scale 10% -scale 1000% \
"$lock" -gravity center -composite -matte "$image"
2018-10-18 19:25:56 +00:00
i3lock_options=("\
--image='$image' \
--insidevercolor=$c5 \
2018-07-21 04:46:57 +00:00
--insidewrongcolor=$c3 \
--insidecolor=$c0 \
--ringvercolor=$c2 \
--ringwrongcolor=$cA \
2018-07-21 04:46:57 +00:00
--ringcolor=$c7 \
--verifcolor=$c8 \
--wrongcolor=$c4 \
2018-08-23 19:00:30 +00:00
--linecolor=$c4 \
--separatorcolor=$c6 \
2018-08-23 19:00:30 +00:00
--keyhlcolor=$c4 \
--bshlcolor=$c3 \
--layoutcolor=$c9 \
--modsize=18 \
2018-08-23 19:00:30 +00:00
--refresh-rate=30 \
--radius=120 \
2018-08-23 19:00:30 +00:00
--ring-width=4 \
--veriftext='' \
--wrongtext='' \
--noinputtext='' \
2018-07-21 04:46:57 +00:00
--ignore-empty-password \
-B \
2018-10-18 19:25:56 +00:00
--nofork &")
#pid="$!"
#while 2>/dev/null kill -0 "$pid"; do
# sleep 1
#done
pre_lock
if [[ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]]; then
kill_i3lock() {
pkill -xu $EUID "$@" i3lock
}
trap kill_i3lock TERM INT
# we have to make sure the locker does not inherit a copy of the lock fd
i3lock "${i3lock_options[@]}" {XSS_SLEEP_LOCK_FD}<&-
# now close our fd (only remaining copy) to indicate we're ready to sleep
exec {XSS_SLEEP_LOCK_FD}<&-
2017-09-04 19:19:36 +00:00
2018-10-18 19:25:56 +00:00
while kill_i3lock -0; do
sleep 0.5
done
else
trap 'kill %%' TERM INT
i3lock -n "${i3lock_options[@]}" &
wait
fi
2017-09-04 19:19:36 +00:00
2018-10-18 19:25:56 +00:00
post_lock