Fix swayidle-lock-screen with safeeyes

This commit is contained in:
2026-03-04 15:31:34 -08:00
parent 4d5ebe465e
commit 0215834891

View File

@ -14,12 +14,21 @@ function has-rootful-xwayland-p {
return 1 return 1
} }
function safeeyes-running-p {
[[ "$(safeeyes --status)" = Next* ]]
}
function run { function run {
# ensure multiple instances do not run # ensure multiple instances do not run
mkdir -p "${LOCKFILE:h}" mkdir -p "${LOCKFILE:h}"
exec 4<>"${LOCKFILE}" exec 4<>"${LOCKFILE}"
flock -n 4 || exit 0 flock -n 4 || exit 0
dunstctl set-paused true dunstctl set-paused true
let need_restore_safeeyes=0
if safeeyes-running-p; then
safeeyes --disable
need_restore_safeeyes=1
fi
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then
swaylock ${empty_flag} --color '#000000' swaylock ${empty_flag} --color '#000000'
else else
@ -35,17 +44,16 @@ function run {
swayidle -w -C /dev/null \ swayidle -w -C /dev/null \
timeout 15 "${(q)ENABLE_DISPLAYS} -d ${ignored_args}" \ timeout 15 "${(q)ENABLE_DISPLAYS} -d ${ignored_args}" \
resume "${(q)ENABLE_DISPLAYS} {$ignored_args}" & resume "${(q)ENABLE_DISPLAYS} {$ignored_args}" &
# after-resume "${(q)RESET_SAFEEYES}" \
swayidle_pid="${!}" swayidle_pid="${!}"
else else
swayidle -w -C /dev/null \ swayidle -w -C /dev/null \
timeout 15 "systemctl sleep" & timeout 15 "systemctl sleep" &
# after-resume "${(q)RESET_SAFEEYES}" \
swayidle_pid="${!}" swayidle_pid="${!}"
fi fi
swaylock ${empty_flag} ${img_flags} swaylock ${empty_flag} ${img_flags}
kill "${swayidle_pid}" kill "${swayidle_pid}"
fi fi
(( need_restore_safeeyes )) && safeeyes --enable
dunstctl set-paused false dunstctl set-paused false
fix_eww fix_eww
flock -u 4 flock -u 4