From 7661be6a695959c8413603e08de4cd74cd581a6d Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Thu, 3 Sep 2026 21:54:35 +0800 Subject: [PATCH] fix: refine shoukei idle screen off --- home/linux/gui/base/hypridle/hypridle.conf | 9 +++++++- .../tests/home-manager/expected.nix | 7 +++++- .../aarch64-linux/tests/home-manager/expr.nix | 22 ++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/home/linux/gui/base/hypridle/hypridle.conf b/home/linux/gui/base/hypridle/hypridle.conf index aadf734a..4b653abe 100644 --- a/home/linux/gui/base/hypridle/hypridle.conf +++ b/home/linux/gui/base/hypridle/hypridle.conf @@ -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 } diff --git a/outputs/aarch64-linux/tests/home-manager/expected.nix b/outputs/aarch64-linux/tests/home-manager/expected.nix index 7ed69ece..273b6dfd 100644 --- a/outputs/aarch64-linux/tests/home-manager/expected.nix +++ b/outputs/aarch64-linux/tests/home-manager/expected.nix @@ -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; +}) diff --git a/outputs/aarch64-linux/tests/home-manager/expr.nix b/outputs/aarch64-linux/tests/home-manager/expr.nix index 5c8ba072..ceeaa107 100644 --- a/outputs/aarch64-linux/tests/home-manager/expr.nix +++ b/outputs/aarch64-linux/tests/home-manager/expr.nix @@ -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" + ]; + } )