#!/bin/sh LOCK_RESOLUTION="1920x1080" LOCK_QUALITY=70 die() { printf '%s: %s\n' "${0##*/}" "$1" >&2 exit 1 } if [ "$1" = "-" ]; then while IFS= read -r line; do input="$line" done else input="$1" fi [ -f "$input" ] || die "$input: no such file" case "$input" in /*) ;; *) die "$input: not an absolute path" ;; esac case "${input##*.}" in png | jpg | jpeg) ;; *) die "$input: unsupported file type" ;; esac magick "$1" -resize "$LOCK_RESOLUTION"^ -gravity center -extent "$LOCK_RESOLUTION" -quality "$LOCK_QUALITY" "$XDG_CACHE_HOME/lock.png" & ln -sf "$input" "$XDG_DATA_HOME/wallpaper" xwallpaper --zoom "$XDG_DATA_HOME/wallpaper" notify-send "${0##*/}" "Set wallpaper to ${input##*/}."