mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-09-14 14:01:45 +02:00
feat(hypridle): define config in home-manager with per-host timeouts
Replace the static hypridle.conf with services.hypridle.settings and add required timeout options so each host tunes its own values: - idols-ai (PC): 15 min keyboard, 20 min screen-off, 30 min lock. - 12kingdoms-shoukei (laptop): 3 / 6 / 20 min (previous values). The options have no defaults because the right values depend on the machine. Update the home-manager eval test to inspect the settings option instead of the old config file text.
This commit is contained in:
@@ -1,9 +1,66 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.modules.desktop.hypridle;
|
||||
in
|
||||
{
|
||||
xdg.configFile."hypr/hypridle.conf".source = ./hypridle.conf;
|
||||
options.modules.desktop.hypridle = {
|
||||
keyboardBacklightTimeout = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "Seconds of idle before turning off the keyboard backlight.";
|
||||
};
|
||||
screenOffTimeout = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "Seconds of idle before turning off the monitors (DPMS).";
|
||||
};
|
||||
lockTimeout = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "Seconds of idle before locking the screen.";
|
||||
};
|
||||
};
|
||||
|
||||
# Hyprland idle daemon
|
||||
services.hypridle.enable = true;
|
||||
config = {
|
||||
# Hyprland/niri idle daemon. Declared in Nix (instead of a raw
|
||||
# hypridle.conf) so each host can tune the timeouts below.
|
||||
services.hypridle = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
general = {
|
||||
lock_cmd = "noctalia-shell ipc call lockScreen lock";
|
||||
before_sleep_cmd = "noctalia-shell ipc call lockScreen lock";
|
||||
ignore_dbus_inhibit = false;
|
||||
};
|
||||
|
||||
listener = [
|
||||
{
|
||||
timeout = cfg.keyboardBacklightTimeout;
|
||||
# brightnessctl --list / -d kbd_backlight
|
||||
on-timeout = "brightnessctl --save --device=kbd_backlight set 0";
|
||||
on-resume = "brightnessctl --restore --device=kbd_backlight";
|
||||
}
|
||||
{
|
||||
timeout = cfg.screenOffTimeout;
|
||||
ignore_inhibit = true;
|
||||
# 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 while an MPRIS player reports
|
||||
# active playback.
|
||||
condition_cmd = "! playerctl -a status 2>/dev/null | grep -q '^Playing$'";
|
||||
condition_retry = 30;
|
||||
on-timeout = "niri msg action power-off-monitors";
|
||||
on-resume = "niri msg action power-on-monitors";
|
||||
}
|
||||
{
|
||||
timeout = cfg.lockTimeout;
|
||||
ignore_inhibit = true;
|
||||
on-timeout = "noctalia-shell ipc call lockScreen lock";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user