hypridle: don't lock/dpms/suspend while MPRIS media is playing

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rope 2026-06-26 15:09:13 +01:00
parent ee630bac30
commit c7b3f8a306

View file

@ -378,7 +378,13 @@ in
};
};
services.hypridle = lib.mkIf isMacbook {
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 = {
@ -389,20 +395,21 @@ in
listener = [
{
timeout = 300; # 5 min — lock
on-timeout = "loginctl lock-session";
on-timeout = unlessPlaying "loginctl lock-session";
}
{
timeout = 420; # 7 min — display off
on-timeout = "hyprctl dispatch dpms off";
on-timeout = unlessPlaying "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
{
timeout = 600; # 10 min — suspend
on-timeout = "systemctl suspend";
on-timeout = unlessPlaying "systemctl suspend";
}
];
};
};
}
);
# Scope all HM Wayland services (hyprpaper, etc.) to the
# Hyprland session so they don't crash-loop in a GNOME session.