From f66452dcd1c4c2c9e4c7ccf0e1395fc42aedf8ca Mon Sep 17 00:00:00 2001 From: 28allday Date: Sat, 9 May 2026 21:08:18 +0100 Subject: [PATCH] fix: suspend access denied after returning from Gaming Mode switch-to-gaming masks sleep/suspend/hibernate targets with --runtime (symlinks in /run/systemd/system/). switch-to-desktop's plain `unmask` plus a missing daemon-reload left logind's CanSuspend cache stale, so `systemctl suspend` returned polkit "Access denied" back on desktop. Add the --runtime unmask and a daemon-reload, plus matching NOPASSWD sudoers entries so the desktop-side script can actually run them. Co-Authored-By: Claude Opus 4.7 (1M context) --- deckshift.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deckshift.sh b/deckshift.sh index 5bd8400..887bcf3 100755 --- a/deckshift.sh +++ b/deckshift.sh @@ -2254,7 +2254,14 @@ if [[ -f "$SAVED_STATE_FILE" ]]; then rm -f "$SAVED_STATE_FILE" fi +# Unmask both /etc and /run masking symlinks (the gaming-mode mask uses +# --runtime, which lives in /run; some systemd versions don't clear it via +# plain `unmask`). Then daemon-reload so logind's CanSuspend cache refreshes +# — without this, `systemctl suspend` returns "Access denied" via polkit even +# though the masks are gone. sudo -n systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null +sudo -n systemctl unmask --runtime sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null +sudo -n systemctl daemon-reload 2>/dev/null sudo -n /usr/local/bin/gaming-session-switch desktop 2>/dev/null || true # Re-enable Bluetooth @@ -2482,6 +2489,8 @@ SESSION_HELPER %video ALL=(ALL) NOPASSWD: /usr/bin/chvt %video ALL=(ALL) NOPASSWD: /usr/bin/systemctl mask --runtime sleep.target suspend.target hibernate.target hybrid-sleep.target %video ALL=(ALL) NOPASSWD: /usr/bin/systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target +%video ALL=(ALL) NOPASSWD: /usr/bin/systemctl unmask --runtime sleep.target suspend.target hibernate.target hybrid-sleep.target +%video ALL=(ALL) NOPASSWD: /usr/bin/systemctl daemon-reload %wheel ALL=(ALL) NOPASSWD: /usr/bin/systemctl start NetworkManager.service %wheel ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop NetworkManager.service %video ALL=(ALL) NOPASSWD: /usr/bin/systemctl start bluetooth.service