109 lines
3.7 KiB
Bash
Executable File
109 lines
3.7 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
#
|
|
# i3lock-custom.bash
|
|
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
|
#
|
|
# Distributed under terms of the MIT license.
|
|
#
|
|
|
|
tmpdir="$(mktemp -d "/tmp/i3lock-custom-$(whoami)-XXXXXXXX")"
|
|
[ -z ${tmpdir+x} ] && exit 2
|
|
cleanup() {
|
|
rm -rf "$tmpdir"
|
|
[ -z "$i3lockpid" ] || kill "$i3lockpid"
|
|
[ -z "$conkypid" ] || kill "$conkypid"
|
|
}
|
|
trap "cleanup" EXIT
|
|
# Papirus Dark's object-locked.svg, rendererd, gzipped and base64'd
|
|
# Also recolored to Gruvbox colors
|
|
# Licensed under the terms of the GPLv3.0 License
|
|
# https://github.com/PapirusDevelopmentTeam/papirus-icon-theme
|
|
lockimg_gz() {
|
|
cat << EOF
|
|
H4sICPMQVFwAA29iamVjdC1sb2NrZWQucG5nALVUaTCbCRj+EnUfjftaRJdoVaMaRasjpHFEURqa
|
|
Elc7aBXVUuqoSK0rzpQ6SpVBHSVli8S1WLWtI8RWibqtTV1NpHXGuXT21/7fd+Y55p15n5n3z0Oy
|
|
t7MUF1ESAQBAHGOFvnaoxCMICRzyO5ObfYcicOuKJRr4MbzLLdGHInzfyjn48IJ5BBDqZH7Y4VLw
|
|
IcbWXHAODBJWPl4BVRIHAP4nGLSZY9gYu8At0clJIb4wcEXx9sBzxDl+KUyKu6Z36i19N19rRSlz
|
|
c8N4eTOsj8PgcdlwHNkR7e2rfd4dzR/it1aSoYgyZJF5fCFPxfZIv5ciggfoYRvbzQrqpbGVvzE+
|
|
79BbGZQBk0jKpvO0y/LXulFoLAQlpH5IiU0x/RsCzelwKAl3iyqzWXU2e2YNyAHc5g/Gjc7G6MWs
|
|
8vlo3UdauB70+u+rSRUNowqV8PHmyomN/OW65sZ87yXBkcKzUcsVPz0F4lQW3WGfOHwC97MNK2jx
|
|
HYK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H7YTi0HcfD08GvQynGY0l1ugsUVAKdSn9W7GyXhu
|
|
Ez90XecKOjorWQDj5hO8MAGkRY8dcbU80kTwnqOF7eyVvz4262h0+5TCpPGyBKyz7bXIBojsj9gS
|
|
9ay9skyyRh+lZOdOmyw0jYPbaoJI/8HHuwriGJ5KbjX4RjWIBukcDJ0Jltuc2uWHsnpUn8ZzTghB
|
|
XcLlHOStAHVQ7NEH/6f5sxOcUqm82sn4okvcqY3pFk6OF7UH+RdmdJNmIlflobFm0JOpZZmQjMkm
|
|
0bN7cPz4q0t5AxLLCybZF9ttsk8M1aTtid2guOZ1PlmtSSvQ7jIYpMNIV5aJNCKap1/79R21upNR
|
|
DXa1F4dZ1qgnCSb6n+EkD/qxPgbWlXuotaeTxXwcNuL+LUAhPUOeaKpbMfl2TJvLUXljzO3Qb1Ce
|
|
Mf8AFA6UTfQFAAA=
|
|
EOF
|
|
}
|
|
|
|
step_produce_image() {
|
|
(
|
|
# Really wanna make damn sure that we handle this well
|
|
set +e
|
|
umask 077
|
|
cd "$tmpdir" || exit
|
|
# I know this is inefficient but it's an easier solution than parsing
|
|
# xrandr
|
|
import -window root scrot.bmp
|
|
lockimg_gz | base64 -d | gunzip > lock.png
|
|
rectangle="rectangle $(convert scrot.bmp -print "0,0 %w,%h" /dev/null)"
|
|
|
|
# Do the do
|
|
# Output is in PNG so i3lock doesn't OOM
|
|
convert \
|
|
scrot.bmp \
|
|
-fill \#383c4a\
|
|
-draw "$rectangle" \
|
|
lock.png -gravity center -compose src-over -composite \
|
|
"$HOME/.face" -gravity center -geometry 128x128+216+0 -compose src-over -composite \
|
|
end.png
|
|
)
|
|
return $?
|
|
}
|
|
step_start_i3lock() {
|
|
i3lock -i "$tmpdir/end.png" &
|
|
i3lockpid="$!"
|
|
}
|
|
step_start_conky() {
|
|
i=0
|
|
while ! xprop -name "i3lock" > /dev/null 2>&1; do
|
|
i=$(( i + 1 ))
|
|
if [ "$i" -eq "100" ]; then
|
|
return 1
|
|
fi
|
|
sleep 0.01
|
|
done
|
|
conkyconfig="$HOME/.config/conky/i3lock.conf"
|
|
[ -r "$conkyconfig" ] || return 2
|
|
conky -c "$conkyconfig" &
|
|
conkypid="$!"
|
|
}
|
|
step_wait() {
|
|
wait
|
|
exit 0
|
|
}
|
|
|
|
main() {
|
|
step_produce_image || exit 1
|
|
step_start_i3lock
|
|
step_start_conky
|
|
step_wait
|
|
}
|
|
|
|
main "$@"
|
|
|