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:
parent
ee630bac30
commit
c7b3f8a306
1 changed files with 31 additions and 24 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue