Update swayidle-lock-screen

This commit is contained in:
Alexander Rosenberg 2024-04-26 04:36:22 -07:00
parent efc5c1ff83
commit 546fa520e8
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -13,7 +13,7 @@ function run {
local swayidle_pid="${!}" local swayidle_pid="${!}"
swaylock ${empty_flag} ${img_flags} swaylock ${empty_flag} ${img_flags}
kill "${swayidle_pid}" kill "${swayidle_pid}"
hyprctl dispatch dpms on eval "${wake_command}"
dunstctl set-paused false dunstctl set-paused false
fix_eww fix_eww
flock -u 4 flock -u 4
@ -26,8 +26,8 @@ function fix_eww {
} }
local background=false local background=false
local suspend_command='hyprctl dispatch dpms off' local suspend_command=''
local wake_command='hyprctl dispatch dpms on' local wake_command=''
local empty_flag='' local empty_flag=''
local fix_eww=() local fix_eww=()
while [[ "${1}" =~ '^-' ]]; do while [[ "${1}" =~ '^-' ]]; do
@ -44,7 +44,12 @@ while [[ "${1}" =~ '^-' ]]; do
shift shift
;; ;;
-s) -s)
local suspend_command='sudo /usr/lib/systemd/systemd-sleep suspend &' local suspend_command="${2}"
shift
;;
-w)
local wake_command="${2}"
shift
;; ;;
-e) -e)
empty_flag='-e' empty_flag='-e'
@ -56,6 +61,18 @@ while [[ "${1}" =~ '^-' ]]; do
shift shift
done done
if [[ -z "${suspend_command}" ]]; then
# default to turning off all displays
suspend_command="wlr-randr $(wlr-randr --json |
jq -r '[.[] | .modes = [.modes.[] |
select(.current)]] |
map("--output ''\(.name)'' --off") | join(" ")')"
fi
if [[ -z "${wake_command}" ]]; then
wake_command="wlr-randr $(wlr-randr --json | jq -r '[.[]| select(.enabled) | .modes = [.modes.[] | select(.current)].[]] | map("--output ''\(.name)'' --on --mode ''\(.modes.width)x\(.modes.height)@\(.modes.refresh)Hz'' --pos ''\(.position.x),\(.position.y)'' --transform \(.transform) --scale \(.scale)") | join(" ")')"
fi
(( ${#} != 0 )) && img_flags=(-s fill -i "${1}") (( ${#} != 0 )) && img_flags=(-s fill -i "${1}")
if ${background}; then if ${background}; then