fix(gaming): keep hypridle down across activations while streaming
A home-manager activation mid-stream restarted the daemon behind the script's back, bringing the 15-minute lock with it. Gate the unit on a runtime stamp so the restart is a silent no-op. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,10 @@ let
|
||||
# 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"
|
||||
# Read by hypridle.service as ConditionPathExists=!%t/sunshine-streaming,
|
||||
# so a home-manager activation mid-stream cannot restart the daemon behind
|
||||
# our back. Lives on tmpfs, so a reboot clears a stamp left by a crash.
|
||||
streaming="$XDG_RUNTIME_DIR/sunshine-streaming"
|
||||
|
||||
# The graphical seat session — NOT the `manager` session that the sunshine
|
||||
# user service itself runs in. Sunshine's environment carries no
|
||||
@@ -72,6 +76,7 @@ let
|
||||
# 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.
|
||||
touch "$streaming"
|
||||
systemctl --user stop hypridle || true
|
||||
|
||||
# No hyprlock running means the session was already unlocked: do
|
||||
@@ -84,6 +89,7 @@ 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.
|
||||
rm -f "$streaming"
|
||||
systemctl --user start hypridle || true
|
||||
|
||||
[ -e "$stamp" ] || exit 0
|
||||
@@ -110,5 +116,10 @@ in
|
||||
|
||||
config = lib.mkIf cfg.sunshineSessionLock {
|
||||
home.packages = [ sunshine-session-lock ];
|
||||
|
||||
# A failed condition makes `systemctl start` a silent no-op rather than an
|
||||
# error, so this only suppresses the restart that home-manager activation
|
||||
# performs; the explicit start in the `lock` path removes the stamp first.
|
||||
systemd.user.services.hypridle.Unit.ConditionPathExists = "!%t/sunshine-streaming";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user