36 lines
812 B
Bash
Executable File
36 lines
812 B
Bash
Executable File
#!/bin/sh
|
|
|
|
BLUR_FACTOR=64;
|
|
|
|
OPTIONAL_CMDS=("convert" "python3" "grim")
|
|
|
|
for CMD in $OPTIONAL_CMDS; do
|
|
if ! command -v "$CMD" &> /dev/null
|
|
then
|
|
echo "$CMD could not be found, falling back to basic mode."
|
|
|
|
swaylock --config ~/.config/sway/swaylock.config --color 302f3b $@
|
|
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
BASE_IMAGE_DIR="$(mktemp -d)"
|
|
INDEX=1
|
|
|
|
image_path() {
|
|
echo "$BASE_IMAGE_DIR/$1.jpg"
|
|
}
|
|
|
|
UPSCALE="$(python3 -c "print(100*$BLUR_FACTOR, end='')")%"
|
|
DOWNSCALE="$(python3 -c "print(100/$BLUR_FACTOR, end='')")%"
|
|
|
|
grim "$(image_path 1)"
|
|
|
|
convert -scale $DOWNSCALE -scale $UPSCALE "$(image_path 1)" "$(image_path 2)"
|
|
convert -composite -gravity center "$(image_path 2)" ~/.config/sway/ferris-stamp.png "$(image_path 3)"
|
|
|
|
swaylock --config ~/.config/sway/swaylock.config --image "$(image_path 3)"
|
|
|
|
rm -r "$BASE_IMAGE_DIR"
|