i3lock-custom: Major refactor
Polish the imagemagick pipeline Be less error-tolerant in subshell Make program flow easier to read And open the gates to having a bar on top of it all
This commit is contained in:
parent
278e3942a2
commit
0ec90646ba
@ -6,10 +6,11 @@
|
|||||||
# Distributed under terms of the MIT license.
|
# Distributed under terms of the MIT license.
|
||||||
#
|
#
|
||||||
|
|
||||||
tmpdir="$(mktemp -d /tmp/i3lock-custom-XXXXXXXX)"
|
tmpdir="$(mktemp -d "/tmp/i3lock-custom-$(whoami)-XXXXXXXX")"
|
||||||
[ -z ${tmpdir+x} ] && exit 2
|
[ -z ${tmpdir+x} ] && exit 2
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
|
[ -z "$i3lockpid" ] || kill "$i3lockpid"
|
||||||
}
|
}
|
||||||
trap "cleanup" EXIT
|
trap "cleanup" EXIT
|
||||||
# Papirus Dark's object-locked.svg, rendererd, gzipped and base64'd
|
# Papirus Dark's object-locked.svg, rendererd, gzipped and base64'd
|
||||||
@ -49,25 +50,45 @@ klg/Tyn9KCMwN3XMDWhrx7stDd1Q4nnRBSHUZn1vrKVXpOqvTAwcKBPunsekzX3q6Z0/Udt6hnii
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
step_produce_image() {
|
||||||
cd "$tmpdir"
|
(
|
||||||
# Take a screenshot
|
# Really wanna make damn sure that we handle this well
|
||||||
import -window root stage1.bmp
|
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)"
|
||||||
|
|
||||||
# Blur out the important bits
|
# Do the do
|
||||||
convert stage1.bmp -blur 10x5 stage2.bmp
|
# Output is in PNG so i3lock doesn't OOM
|
||||||
|
convert \
|
||||||
|
scrot.bmp \
|
||||||
|
-blur 10x5 \
|
||||||
|
-fill \#282828 \
|
||||||
|
-draw "$rectangle" \
|
||||||
|
lock.png -gravity center -compose Exclusion -composite \
|
||||||
|
end.png
|
||||||
|
)
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
step_start_i3lock() {
|
||||||
|
i3lock -i "$tmpdir/end.png" &
|
||||||
|
i3lockpid="$!"
|
||||||
|
}
|
||||||
|
step_wait() {
|
||||||
|
wait
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# Put a grey bar over it
|
main() {
|
||||||
rectangle="rectangle $(convert stage2.bmp -print "0,%[fx:h/2+128] %w,%[fx:h/2-128]" /dev/null)"
|
step_produce_image || exit 1
|
||||||
convert stage2.bmp -fill \#282828 -draw "$rectangle" stage3.bmp
|
step_start_i3lock
|
||||||
|
step_wait
|
||||||
|
wait
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# Stick a lock icon on there
|
main $@
|
||||||
lockimg_gz | base64 -d | gunzip > lock.png
|
|
||||||
convert -compose Exclusion -composite -gravity center stage3.bmp lock.png stage4.bmp
|
|
||||||
|
|
||||||
# Convert the output to PNG so i3lock doesn't OOM
|
|
||||||
convert stage4.bmp end.png
|
|
||||||
)
|
|
||||||
|
|
||||||
i3lock -i "$tmpdir/end.png"
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user