From 3f9918caf977bcf643b25f7874dc3d419cee2c83 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 30 Jul 2024 16:34:06 -0400 Subject: [PATCH] home.desktop: generic autoSuspend, randomWallpaper, and redShift options (#67) * move sway/hyprland autoSuspend settings to desktop module * mauville: migrate settings * migrate missing if statements * home/desktop: move randomWallpaper to to desktop * migrate randomWallpaper * home: migrate redShift options to desktop --- .../desktop/hyprland/scripts.nix | 4 +- .../desktop/hyprland/settings.nix | 9 ++-- homeManagerModules/desktop/sway/scripts.nix | 4 +- homeManagerModules/desktop/sway/settings.nix | 6 +-- homeManagerModules/options.nix | 54 +++++++------------ homes/dustin/default.nix | 17 +++--- hosts/mauville/home.nix | 4 +- 7 files changed, 39 insertions(+), 59 deletions(-) diff --git a/homeManagerModules/desktop/hyprland/scripts.nix b/homeManagerModules/desktop/hyprland/scripts.nix index 802023bf..5cd0abb9 100644 --- a/homeManagerModules/desktop/hyprland/scripts.nix +++ b/homeManagerModules/desktop/hyprland/scripts.nix @@ -30,7 +30,7 @@ in { timeouts = ["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"] ++ ( - if cfg.desktop.hyprland.autoSuspend + if cfg.desktop.autoSuspend then ["timeout 600 '${lib.getExe' pkgs.systemd "systemctl"} suspend'"] else [ "timeout 600 '${lib.getExe pkgs.swaylock}'" @@ -39,7 +39,7 @@ in { ); beforeSleeps = - lib.optionals cfg.desktop.hyprland.autoSuspend + lib.optionals cfg.desktop.autoSuspend [ "before-sleep '${lib.getExe pkgs.playerctl} pause'" "before-sleep '${lib.getExe pkgs.swaylock}'" diff --git a/homeManagerModules/desktop/hyprland/settings.nix b/homeManagerModules/desktop/hyprland/settings.nix index 7628b83b..2cf65925 100644 --- a/homeManagerModules/desktop/hyprland/settings.nix +++ b/homeManagerModules/desktop/hyprland/settings.nix @@ -125,7 +125,6 @@ in { exec-once = [ - helpers.wallpaperD (lib.getExe pkgs.waybar) scripts.idleD (lib.getExe pkgs.wayland-pipewire-idle-inhibit) @@ -134,8 +133,12 @@ in { (lib.getExe pkgs.mako) "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1" ] - ++ lib.lists.optional (cfg.desktop.hyprland.redShift) - "${lib.getExe pkgs.gammastep} -l 33.74:-84.38"; + ++ lib.lists.optional (cfg.desktop.redShift) + "${lib.getExe pkgs.gammastep} -l 33.74:-84.38" + ++ lib.lists.optional (cfg.desktop.randomWallpaper) + helpers.wallpaperD + ++ lib.lists.optional (!cfg.desktop.randomWallpaper) + "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}"; input = { follow_mouse = 1; diff --git a/homeManagerModules/desktop/sway/scripts.nix b/homeManagerModules/desktop/sway/scripts.nix index 22652920..add1073d 100644 --- a/homeManagerModules/desktop/sway/scripts.nix +++ b/homeManagerModules/desktop/sway/scripts.nix @@ -11,7 +11,7 @@ in { timeouts = ["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"] ++ ( - if cfg.desktop.sway.autoSuspend + if cfg.desktop.autoSuspend then ["timeout 600 '${lib.getExe' pkgs.systemd "systemctl"} suspend'"] else [ "timeout 600 '${lib.getExe pkgs.swaylock}'" @@ -20,7 +20,7 @@ in { ); beforeSleeps = - lib.optionals cfg.desktop.sway.autoSuspend + lib.optionals cfg.desktop.autoSuspend [ "before-sleep '${lib.getExe pkgs.playerctl} pause'" "before-sleep '${lib.getExe pkgs.swaylock}'" diff --git a/homeManagerModules/desktop/sway/settings.nix b/homeManagerModules/desktop/sway/settings.nix index 91459a5e..9a98572c 100644 --- a/homeManagerModules/desktop/sway/settings.nix +++ b/homeManagerModules/desktop/sway/settings.nix @@ -165,10 +165,10 @@ in { {command = lib.getExe' pkgs.swayosd "swayosd-server";} {command = lib.getExe pkgs.mako;} ] - ++ lib.optional cfg.desktop.sway.redShift + ++ lib.optional cfg.desktop.redShift {command = "${lib.getExe pkgs.gammastep} -l 33.74:-84.38";} - ++ lib.optional cfg.desktop.sway.randomWallpaper {command = "${helpers.wallpaperD}";} - ++ lib.optional (!cfg.desktop.sway.randomWallpaper) {command = "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";}; + ++ lib.optional cfg.desktop.randomWallpaper {command = "${helpers.wallpaperD}";} + ++ lib.optional (!cfg.desktop.randomWallpaper) {command = "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";}; floating.criteria = [ {app_id = ".blueman-manager-wrapped";} diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index e6fb3754..b0caa9c0 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -107,6 +107,24 @@ in { }; desktop = { + autoSuspend = lib.mkOption { + description = "Whether to autosuspend on idle."; + default = cfg.desktop.hyprland.enable || cfg.desktop.sway.enable; + type = lib.types.bool; + }; + + randomWallpaper = lib.mkOption { + description = "Whether to enable random wallpaper script."; + default = cfg.desktop.hyprland.enable || cfg.desktop.sway.enable; + type = lib.types.bool; + }; + + redShift = lib.mkOption { + description = "Whether to redshift display colors at night."; + default = cfg.desktop.hyprland.enable || cfg.desktop.sway.enable; + type = lib.types.bool; + }; + hyprland = { enable = lib.mkOption { description = "Hyprland with full desktop session components."; @@ -114,12 +132,6 @@ in { type = lib.types.bool; }; - autoSuspend = lib.mkOption { - description = "Whether to autosuspend on idle."; - default = cfg.desktop.hyprland.enable; - type = lib.types.bool; - }; - laptopMonitors = lib.mkOption { description = "List of internal laptop monitors."; default = []; @@ -132,18 +144,6 @@ in { type = lib.types.listOf lib.types.str; }; - randomWallpaper = lib.mkOption { - description = "Whether to enable random wallpaper script."; - default = cfg.desktop.hyprland.enable; - type = lib.types.bool; - }; - - redShift = lib.mkOption { - description = "Whether to redshift display colors at night."; - default = cfg.desktop.hyprland.enable; - type = lib.types.bool; - }; - windowManagerBinds = lib.mkOption { description = "Default binds for window management."; default = { @@ -195,24 +195,6 @@ in { type = lib.types.bool; }; - autoSuspend = lib.mkOption { - description = "Whether to autosuspend on idle."; - default = cfg.desktop.sway.enable; - type = lib.types.bool; - }; - - randomWallpaper = lib.mkOption { - description = "Whether to enable random wallpaper script."; - default = cfg.desktop.sway.enable; - type = lib.types.bool; - }; - - redShift = lib.mkOption { - description = "Whether to redshift display colors at night."; - default = cfg.desktop.sway.enable; - type = lib.types.bool; - }; - windowManagerBinds = lib.mkOption { description = "Default binds for window management."; default = { diff --git a/homes/dustin/default.nix b/homes/dustin/default.nix index 4eb19904..0c2169f2 100644 --- a/homes/dustin/default.nix +++ b/homes/dustin/default.nix @@ -46,17 +46,12 @@ self: { defaultApps.enable = true; desktop = { - hyprland = { - monitors = [ - "desc:Guangxi Century Innovation Display Electronics Co. Ltd 27C1U-D 0000000000001,preferred,-2400x0,1.6" - "desc:HP Inc. HP 24mh 3CM037248S,preferred,-1920x0,auto" - "desc:LG Electronics LG IPS QHD 109NTWG4Y865,preferred,-2560x0,auto" - ]; - - randomWallpaper = false; - }; - - sway.randomWallpaper = false; + hyprland.monitors = [ + "desc:Guangxi Century Innovation Display Electronics Co. Ltd 27C1U-D 0000000000001,preferred,-2400x0,1.6" + "desc:HP Inc. HP 24mh 3CM037248S,preferred,-1920x0,auto" + "desc:LG Electronics LG IPS QHD 109NTWG4Y865,preferred,-2560x0,auto" + ]; + randomWallpaper = false; }; theme = { diff --git a/hosts/mauville/home.nix b/hosts/mauville/home.nix index 9f8b31a7..770e974c 100644 --- a/hosts/mauville/home.nix +++ b/hosts/mauville/home.nix @@ -11,9 +11,9 @@ xdg.userDirs.music = "/mnt/Media/Music"; ar.home = { - desktop.hyprland = { + desktop = { autoSuspend = false; - monitors = ["desc:LG Electronics LG ULTRAWIDE 311NTAB5M720,preferred,auto,1.25,vrr,2"]; + hyprland.monitors = ["desc:LG Electronics LG ULTRAWIDE 311NTAB5M720,preferred,auto,1.25,vrr,2"]; }; theme.darkMode = false;