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
|
||||
|
37
way-displays-enable
Executable file
37
way-displays-enable
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
let just_list=0
|
||||
local operation="-d"
|
||||
local jq_filter_neg="| not"
|
||||
local ignored=()
|
||||
|
||||
while getopts 'ldi:' name; do
|
||||
case "${name}" in
|
||||
l)
|
||||
just_list=1
|
||||
;;
|
||||
d)
|
||||
jq_filter_neg=""
|
||||
operation="-s"
|
||||
;;
|
||||
i)
|
||||
ignored+="${OPTARG}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
SCRIPT=".[] | select(.enabled${jq_filter_neg}) | .name"
|
||||
|
||||
set -e
|
||||
displays=("${(0)$(wlr-randr --json | jq --raw-output0 "${SCRIPT}")}")
|
||||
set +e
|
||||
|
||||
displays=(${displays:|ignored})
|
||||
|
||||
if ((just_list)); then
|
||||
printf '%s\0' ${displays}
|
||||
else
|
||||
for display in ${displays}; do
|
||||
way-displays "${operation}" DISABLED "${display}"
|
||||
done
|
||||
fi
|
Reference in New Issue
Block a user