110 lines
3.8 KiB
Bash
Executable File
110 lines
3.8 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
|
|
H4sICEChtlsAA2xvY2sucG5nAK1VazjTexz/bWtsf6TLFmrFStG2sCJdlsty25Al5LIVc6vndMdJ
|
|
kvNvLg2pSCEtyhTKdYdMLus4pUSiyJBthQgR5pKc5+h5zqvznJfnxefyfJ7n+30+r77feNY+ew1o
|
|
NQQA0GA42LguKvwTGJVFrrfwe7UoKlxHexswDLpBGXLKVrKYYE85eIUsTrz/CQTdMDN8MVQNZTjb
|
|
qn6Elmhpm4wReTIA0EqGjbVbeNeogHMM564dJzsZ1J3bX9xmZEnG5XL496z4HdrRdJx+efcKBiZO
|
|
baUa325lcl4y2TQ5j0rC0HP6/8DEJ2FvbjRDlvo6VFvzHeZ8oCUx3t6jmhW/PBZNnkNQI6xdM6QC
|
|
6eg8+3Fwy+2ZnbKdwcEGqGV0DDHmJwVU6omjLh7/dp91Z+nrA76b1MWqCTogAfQgfPuaLYdRb9DZ
|
|
ajxRiTIVbGGYRWFa+L+6wpScBadjFX5d5OwyjISi+v4oKoLAHRFpnP8cc9SsYTPsIo4w80iXnbR8
|
|
kOBtN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PcUGFQsiUX+LSNX7hz58+czEGMPRKLw97FWJ4EIF1xTNCjPFXH9k
|
|
U3yQU1e0IYKw3RoBcLtIetvSNtZ8Cdd33SmfMnRAlI0MCdlPphW02RjkMsgKgUHr4WAWoP/L9G0v
|
|
slzdEVV7+uZRx0LSHWCCt6j8LOifQlQarlelMNpdKD4TicZofkMmz5Z7nMfFkx27ShD5w3Hijljd
|
|
nEoDK1ovjsJTroUb0vfb7ehMknDN9U8F3l8VXx6vCE6d8/e7MJgIvfm5PznFnzKvYxCYQA1mn2vH
|
|
upDhoy+ZcWPYIOaod0sawNNeU2j+d3WnQW7T023MBT2J4YBcJ2dBD7zkGoL/Lv8/GylFkkWwaxlU
|
|
RoO09GjzPDX/MU+wXNpiWG2dPU/TkqS47QGZpwNupyKkCjEw7w0khzVteNt/uAJvX+ATeRoajBOv
|
|
klg/Tyn9KCMwN3XMDWhrx7stDd1Q4nnRBSHUZn1vrKVXpOqvTAwcKBPunsekzX3q6Z0/Udt6hnii
|
|
2uJO8Y2Q8CYP+T0wr5Hdm1Tm8s/BjbmmeCkz9apwtGwb4i7+BMCw3WdTRPfl/Q0o9nFBaAYAAA==
|
|
EOF
|
|
}
|
|
|
|
step_produce_image() {
|
|
(
|
|
# Really wanna make damn sure that we handle this well
|
|
set +e
|
|
umask 077
|
|
cd "$tmpdir"
|
|
# Grab a screenshot and perform some calculations to make our black bar
|
|
import -window root scrot.bmp
|
|
lockimg_gz | base64 -d | gunzip > lock.png
|
|
rectangle="rectangle $(convert scrot.bmp -print "0,%[fx:h/2+128] %w,%[fx:h/2-128]" /dev/null)"
|
|
|
|
# Do the do
|
|
# Output is in PNG so i3lock doesn't OOM
|
|
convert \
|
|
scrot.bmp \
|
|
-blur 10x5 \
|
|
-fill \#282828 \
|
|
-draw "$rectangle" \
|
|
lock.png -gravity center -compose src-over -composite \
|
|
"$HOME/.face" -gravity center -geometry 128x128+200+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 $@
|
|
|