2023-09-10 03:11:44 -07:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2023-09-10 03:26:19 -07:00
|
|
|
function run {
|
2023-10-05 22:38:52 -07:00
|
|
|
dunstctl set-paused true
|
2023-09-10 03:26:19 -07:00
|
|
|
swayidle -w -C /dev/null \
|
|
|
|
timeout 15 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' &
|
2023-09-10 18:51:02 -07:00
|
|
|
local swayidle_pid="${!}"
|
2023-11-14 20:54:20 -08:00
|
|
|
swaylock -e ${img_flags}
|
2023-09-10 03:26:19 -07:00
|
|
|
kill "${swayidle_pid}"
|
|
|
|
hyprctl dispatch dpms on
|
2023-10-05 22:38:52 -07:00
|
|
|
dunstctl set-paused false
|
2023-11-14 20:54:20 -08:00
|
|
|
fix_eww
|
|
|
|
}
|
|
|
|
|
|
|
|
function fix_eww {
|
2023-11-14 22:00:14 -08:00
|
|
|
if (( ${#fix_eww} > 0 )); then
|
|
|
|
eww open-many ${fix_eww}
|
|
|
|
fi
|
2023-09-10 03:26:19 -07:00
|
|
|
}
|
|
|
|
|
2023-09-10 18:51:02 -07:00
|
|
|
local background=false
|
2023-11-14 20:54:20 -08:00
|
|
|
local fix_eww=()
|
|
|
|
while [[ "${1}" =~ '^-' ]]; do
|
|
|
|
case "${1}" in
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
2023-09-10 18:51:02 -07:00
|
|
|
-f)
|
|
|
|
background=true
|
2023-11-14 20:54:20 -08:00
|
|
|
;;
|
|
|
|
-b)
|
|
|
|
fix_eww+="${2}"
|
|
|
|
shift
|
2023-09-10 18:51:02 -07:00
|
|
|
;;
|
|
|
|
-*)
|
2023-11-14 20:54:20 -08:00
|
|
|
printf "error: unknown flag '%s'\n" "${1}" >&2
|
2023-09-10 18:51:02 -07:00
|
|
|
;;
|
|
|
|
esac
|
2023-11-14 20:54:20 -08:00
|
|
|
shift
|
2023-09-10 18:51:02 -07:00
|
|
|
done
|
|
|
|
|
2023-11-14 20:54:20 -08:00
|
|
|
(( ${#} != 0 )) && img_flags=(-s fill -i "${1}")
|
2023-09-10 18:51:02 -07:00
|
|
|
|
|
|
|
if ${background}; then
|
2023-11-14 20:54:20 -08:00
|
|
|
run '${img_flags}' &
|
2023-09-10 03:26:19 -07:00
|
|
|
else
|
2023-11-14 20:54:20 -08:00
|
|
|
run '${img_flags}'
|
2023-09-10 03:26:19 -07:00
|
|
|
fi
|