From 1d973ec606e73e976a16cac0e95f7d71a0d3f30e Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 7 Jun 2024 00:25:50 -0700 Subject: [PATCH] Make swayidle-lock-screen work with rootful Xwayland --- swayidle-lock-screen | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/swayidle-lock-screen b/swayidle-lock-screen index 72b50f5..1702ec3 100755 --- a/swayidle-lock-screen +++ b/swayidle-lock-screen @@ -2,18 +2,32 @@ LOCKFILE="${HOME}/.cache/swayidle-lock-screen.lock" +function has-rootful-xwayland-p { + for pid in $(pgrep Xwayland); do + local cmdline=(${(0)"$(cat /proc/"${pid}"/cmdline)"}) + if ! ((${cmdline[(Ie)-rootless]})); then + return 0 + fi + done + return 1 +} + function run { # ensure multiple instances do not run mkdir -p "$(dirname "${LOCKFILE}")" exec 4<>"${LOCKFILE}" flock -n 4 || exit 0 dunstctl set-paused true - swayidle -w -C /dev/null \ - timeout 15 "${suspend_command}" resume "${wake_command}" & - local swayidle_pid="${!}" - swaylock ${empty_flag} ${img_flags} - kill "${swayidle_pid}" - eval "${wake_command}" + if has-rootful-xwayland-p; then + swaylock ${empty_flag} --color '#000000' + else + swayidle -w -C /dev/null \ + timeout 15 "${suspend_command}" resume "${wake_command}" & + local swayidle_pid="${!}" + swaylock ${empty_flag} ${img_flags} + kill "${swayidle_pid}" + eval "${wake_command}" + fi dunstctl set-paused false fix_eww flock -u 4