diff --git a/settings/hyprland.nix b/settings/hyprland.nix index dd0737f..a6b608a 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -378,31 +378,38 @@ in }; }; - services.hypridle = lib.mkIf isMacbook { - enable = true; - settings = { - general = { - lock_cmd = "pidof hyprlock || hyprlock"; - before_sleep_cmd = "loginctl lock-session"; - after_sleep_cmd = "hyprctl dispatch dpms on"; + services.hypridle = lib.mkIf isMacbook ( + let + # Skip the action if any MPRIS player is playing — covers windowed + # video (Jellyfin in a browser, mpv, …) that the fullscreen + # idle_inhibit rule misses. Browsers expose MPRIS via playerctl. + unlessPlaying = cmd: "playerctl -a status 2>/dev/null | grep -q Playing || ${cmd}"; + in { + enable = true; + settings = { + general = { + lock_cmd = "pidof hyprlock || hyprlock"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + }; + listener = [ + { + timeout = 300; # 5 min — lock + on-timeout = unlessPlaying "loginctl lock-session"; + } + { + timeout = 420; # 7 min — display off + on-timeout = unlessPlaying "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + { + timeout = 600; # 10 min — suspend + on-timeout = unlessPlaying "systemctl suspend"; + } + ]; }; - listener = [ - { - timeout = 300; # 5 min — lock - on-timeout = "loginctl lock-session"; - } - { - timeout = 420; # 7 min — display off - on-timeout = "hyprctl dispatch dpms off"; - on-resume = "hyprctl dispatch dpms on"; - } - { - timeout = 600; # 10 min — suspend - on-timeout = "systemctl suspend"; - } - ]; - }; - }; + } + ); # Scope all HM Wayland services (hyprpaper, etc.) to the # Hyprland session so they don't crash-loop in a GNOME session.