fix(gaming): stop hypridle while a stream is connected
CI / lint (push) Successful in 27s
CI / eval (push) Successful in 2m11s

Gamepad input comes in on a uinput joystick, which is not part of the
wl_seat, so it never resets Hyprland's idle notifier. Controller-only
play read as idle and the 900s listener locked mid-game. The dbus
inhibitor cannot help here because hypridle runs with
ignore_dbus_inhibit = true.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-09-18 11:04:20 +01:00
co-authored by Claude
parent 591f2be7f5
commit db5df263b2
@@ -43,7 +43,10 @@ let
pkgs.procps
];
text = ''
stamp="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/sunshine-session-unlocked"
# systemctl --user reaches the session manager through $XDG_RUNTIME_DIR/bus;
# sunshine's environment does not always carry the variable.
export XDG_RUNTIME_DIR="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
stamp="$XDG_RUNTIME_DIR/sunshine-session-unlocked"
# The graphical seat session — NOT the `manager` session that the sunshine
# user service itself runs in. Sunshine's environment carries no
@@ -63,6 +66,14 @@ let
case "''${1:-}" in
unlock)
# Gamepad input arrives on a uinput joystick, which is not part of the
# wl_seat, so it never resets Hyprland's idle notifier: controller-only
# play looks idle and the 900s listener locks mid-game. The dbus
# inhibitor cannot prevent this either, because hypridle runs with
# ignore_dbus_inhibit = true (see hyprland/default.nix). Stopping the
# daemon for the life of the stream is the only lever left.
systemctl --user stop hypridle || true
# No hyprlock running means the session was already unlocked: do
# nothing, and leave no stamp so `lock` won't lock it on the way out.
if pkill -u "$(id -u)" -USR1 -x hyprlock; then
@@ -71,6 +82,10 @@ let
;;
lock)
# Before the stamp check: idle timers must come back even when the
# stream arrived at an already-unlocked session and left no stamp.
systemctl --user start hypridle || true
[ -e "$stamp" ] || exit 0
rm -f "$stamp"
s="$(graphical_session)" || exit 0