diff --git a/swayidle-lock-screen b/swayidle-lock-screen index d025479..72b50f5 100755 --- a/swayidle-lock-screen +++ b/swayidle-lock-screen @@ -13,7 +13,7 @@ function run { local swayidle_pid="${!}" swaylock ${empty_flag} ${img_flags} kill "${swayidle_pid}" - hyprctl dispatch dpms on + eval "${wake_command}" dunstctl set-paused false fix_eww flock -u 4 @@ -26,8 +26,8 @@ function fix_eww { } local background=false -local suspend_command='hyprctl dispatch dpms off' -local wake_command='hyprctl dispatch dpms on' +local suspend_command='' +local wake_command='' local empty_flag='' local fix_eww=() while [[ "${1}" =~ '^-' ]]; do @@ -44,7 +44,12 @@ while [[ "${1}" =~ '^-' ]]; do shift ;; -s) - local suspend_command='sudo /usr/lib/systemd/systemd-sleep suspend &' + local suspend_command="${2}" + shift + ;; + -w) + local wake_command="${2}" + shift ;; -e) empty_flag='-e' @@ -56,6 +61,18 @@ while [[ "${1}" =~ '^-' ]]; do shift 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}") if ${background}; then