From 48c501e9c2f2186c810a232c5c87aa19dd4522c4 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 10 Sep 2023 18:51:02 -0700 Subject: [PATCH] Images in swayidle-lock-screen --- swayidle-lock-screen | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/swayidle-lock-screen b/swayidle-lock-screen index 2f3a3cc..5f8a04f 100755 --- a/swayidle-lock-screen +++ b/swayidle-lock-screen @@ -3,14 +3,31 @@ function run { swayidle -w -C /dev/null \ timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' & - local swayidle_pid="$!" - swaylock + local swayidle_pid="${!}" + swaylock -e "${@}" kill "${swayidle_pid}" hyprctl dispatch dpms on } -if [[ "${1}" == '-f' ]]; then - run & +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 + run ${img_flags} fi