#!/usr/bin/env zsh function run { dunstctl set-paused true swayidle -w -C /dev/null \ timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' & local swayidle_pid="${!}" swaylock -e "${@}" kill "${swayidle_pid}" hyprctl dispatch dpms on dunstctl set-paused false } local background=false let img_index=1 for arg; do case "${arg}" in -f) background=true ((++img_index)) ;; -*) printf "error: unknown flag '%s'\n" "${arg}" >&2 ((++img_index)) ;; esac done (( ${#} >= ${img_index} )) && img_flags=(-s fill -i "${@[${img_index}]}") if ${background}; then run ${img_flags} & else run ${img_flags} fi