Fix sleep and wake on lock screen
This commit is contained in:
@ -21,12 +21,20 @@ function run {
|
||||
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then
|
||||
swaylock ${empty_flag} --color '#000000'
|
||||
else
|
||||
# get the list of currently disabled monitors so we don't touch them
|
||||
local ignored=("${(0)$(way-displays-enable -l)}")
|
||||
local ignored_args=()
|
||||
for name in ${ignored}; do
|
||||
# quote so it can be safely passed to swayidle
|
||||
ignored_args+=(-i "${(q)name}")
|
||||
done
|
||||
|
||||
swayidle -w -C /dev/null \
|
||||
timeout 15 "${suspend_command}" resume "${wake_command}" &
|
||||
timeout 15 "way-displays-enable -d ${ignored}" \
|
||||
resume "way-displays-enable {$ignored}" &
|
||||
local swayidle_pid="${!}"
|
||||
swaylock ${empty_flag} ${img_flags}
|
||||
kill "${swayidle_pid}"
|
||||
eval "${wake_command}"
|
||||
fi
|
||||
dunstctl set-paused false
|
||||
fix_eww
|
||||
@ -57,14 +65,6 @@ while [[ "${1}" =~ '^-' ]]; do
|
||||
fix_eww+="${2}"
|
||||
shift
|
||||
;;
|
||||
-s)
|
||||
local suspend_command="${2}"
|
||||
shift
|
||||
;;
|
||||
-w)
|
||||
local wake_command="${2}"
|
||||
shift
|
||||
;;
|
||||
-e)
|
||||
empty_flag='-e'
|
||||
;;
|
||||
@ -75,18 +75,6 @@ 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
|
||||
|
Reference in New Issue
Block a user