From 4f2f4c9b5297eefe6a44cd62e1567373d309d6e5 Mon Sep 17 00:00:00 2001 From: reidlab Date: Sat, 4 Apr 2026 00:27:55 -0700 Subject: [PATCH] compromise for no suspend --- hosts/flubber-machine/default.nix | 1 + modules/desktop/hypridle.nix | 28 +++++++++++++--------------- modules/hardware/rgb.nix | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 modules/hardware/rgb.nix diff --git a/hosts/flubber-machine/default.nix b/hosts/flubber-machine/default.nix index e7764b9..a37e531 100755 --- a/hosts/flubber-machine/default.nix +++ b/hosts/flubber-machine/default.nix @@ -42,6 +42,7 @@ pointer.enable = true; tablet.enable = true; networking.enable = true; + rgb.enable = true; }; dev = { enable = true; diff --git a/modules/desktop/hypridle.nix b/modules/desktop/hypridle.nix index 9740670..3d208cb 100644 --- a/modules/desktop/hypridle.nix +++ b/modules/desktop/hypridle.nix @@ -11,12 +11,7 @@ in { default = inputs.hypridle.packages.${system}.hypridle; example = "pkgs.hypridle"; }; - desktop = mkEnableOption "Enable desktop tweaks (greatly extends the idle timeout)"; - desktopMultiplier = mkOption { - type = types.int; - default = 10; - example = 10; - }; + desktop = mkEnableOption "Extend screen dimming time and disable sleeping"; }; config = mkIf cfg.enable { @@ -30,12 +25,17 @@ in { lock_cmd = "${pkgs.procps}/bin/pidof hyprlock || ${lib.getExe config.modules.desktop.hyprlock.package}"; unlock_cmd = "${pkgs.procps}/bin/pkill -USR1 hyprlock"; - before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session"; # lock the screen before sleeping + before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session"; }; - listener = let - toDesktopTimeout = t: if cfg.desktop then t * cfg.desktopMultiplier else t; - in [ + listener = [ + { + timeout = if !cfg.desktop + then 60 * 2 # 2 min + else 60 * 35; # 35 min + on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer + } + ] ++ optionals (!cfg.desktop) [ { timeout = toDesktopTimeout 60; # 1 min on-timeout = "${lib.getExe pkgs.brightnessctl} -c backlight -s set 20"; # dim screen, save brightness state @@ -46,16 +46,14 @@ in { on-timeout = "${lib.getExe pkgs.brightnessctl} -d '*:kbd_backlight' -s set 0"; # turn off keyboard backlight, save state on-resume = "${lib.getExe pkgs.brightnessctl} -d '*:kbd_backlight' -r"; # restore previous keyboard backlight state } - { - timeout = toDesktopTimeout (60 * 2); # 2 min - on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer - } { timeout = toDesktopTimeout (60 * 15); # 15 min on-timeout = "${pkgs.systemd}/bin/systemctl suspend"; # sleep/suspend } ] ++ optional config.modules.desktop.niri.enable { - timeout = toDesktopTimeout (60 + 30); # 1.5 min + timeout = if !cfg.desktop + then 90 # 1.5 min + else 30 * 60; # 30 min on-timeout = "niri msg action power-off-monitors"; }; }; diff --git a/modules/hardware/rgb.nix b/modules/hardware/rgb.nix new file mode 100644 index 0000000..610723f --- /dev/null +++ b/modules/hardware/rgb.nix @@ -0,0 +1,14 @@ +{ pkgs, config, lib, ... }: + +with lib; +let + cfg = config.modules.hardware.rgb; +in { + options.modules.hardware.rgb = { + enable = mkEnableOption "Enable support for rgb devices through openrgb"; + }; + + config = mkIf cfg.enable { + services.hardware.openrgb.enable = true; + }; +}