fix: refine shoukei idle screen off

This commit is contained in:
Ryan Yin
2026-09-03 23:26:03 +08:00
parent 1ec29059ad
commit 7661be6a69
3 changed files with 35 additions and 3 deletions
+8 -1
View File
@@ -18,14 +18,21 @@ listener {
# the user had made those adjustments. niri (26.04) has no built-in idle timers,
# so hypridle stays responsible for keyboard backlight, dpms and locking below.
# Some apps keep idle-inhibit active even when they are only sitting on a page,
# which can prevent screen-off forever. Ignore those inhibitors for screen-off,
# but skip the action while an MPRIS player reports active playback.
listener {
timeout = 900 # 15 minutes
timeout = 360 # 6 minutes
ignore_inhibit = true
condition_cmd = ! playerctl -a status 2>/dev/null | grep -q '^Playing$'
condition_retry = 30
on-timeout = niri msg action power-off-monitors # DPMS off via niri
on-resume = niri msg action power-on-monitors # DPMS on via niri
}
listener {
timeout = 1200 # 20 minutes
ignore_inhibit = true
on-timeout = noctalia-shell ipc call lockScreen lock # lock screen
}
@@ -8,4 +8,9 @@ let
"shoukei-niri"
];
in
lib.genAttrs hosts (_: "/home/${username}")
lib.genAttrs hosts (_: {
homeDirectory = "/home/${username}";
hypridleScreenOffIgnoresInhibitors = true;
hypridleScreenOffSkipsPlayingMedia = true;
hypridleLockIgnoresInhibitors = true;
})
@@ -10,5 +10,25 @@ let
];
in
lib.genAttrs hosts (
name: outputs.nixosConfigurations.${name}.config.home-manager.users.${username}.home.homeDirectory
name:
let
hm = outputs.nixosConfigurations.${name}.config.home-manager.users.${username};
hypridleConfig = builtins.readFile hm.xdg.configFile."hypr/hypridle.conf".source;
hasHypridleLines = lines: lib.hasInfix (lib.concatStringsSep "\n" lines) hypridleConfig;
in
{
homeDirectory = hm.home.homeDirectory;
hypridleScreenOffIgnoresInhibitors = hasHypridleLines [
" timeout = 360 # 6 minutes"
" ignore_inhibit = true"
];
hypridleScreenOffSkipsPlayingMedia = hasHypridleLines [
" condition_cmd = ! playerctl -a status 2>/dev/null | grep -q '^Playing$'"
" condition_retry = 30"
];
hypridleLockIgnoresInhibitors = hasHypridleLines [
" timeout = 1200 # 20 minutes"
" ignore_inhibit = true"
];
}
)