From 011565307f51990664ad6e515ad47417449726d6 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 2 Aug 2024 14:42:35 -0400 Subject: [PATCH] home: move swayidle and swayosd to services --- homeManagerModules/apps/default.nix | 2 - homeManagerModules/apps/swayidle/default.nix | 63 ------------------- homeManagerModules/apps/swayosd/default.nix | 9 --- .../desktop/wayland/default.nix | 20 +++--- homeManagerModules/options.nix | 5 +- homeManagerModules/services/default.nix | 2 + 6 files changed, 17 insertions(+), 84 deletions(-) delete mode 100644 homeManagerModules/apps/swayidle/default.nix delete mode 100644 homeManagerModules/apps/swayosd/default.nix diff --git a/homeManagerModules/apps/default.nix b/homeManagerModules/apps/default.nix index d3931426..395e2eb6 100644 --- a/homeManagerModules/apps/default.nix +++ b/homeManagerModules/apps/default.nix @@ -15,9 +15,7 @@ ./mako ./nemo ./rofi - ./swayidle ./swaylock - ./swayosd ./thunar ./tmux ./vsCodium diff --git a/homeManagerModules/apps/swayidle/default.nix b/homeManagerModules/apps/swayidle/default.nix deleted file mode 100644 index 05e0d0dc..00000000 --- a/homeManagerModules/apps/swayidle/default.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.ar.home; - hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; - swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg"; - -in { - config = lib.mkIf cfg.apps.swayidle.enable { - services.swayidle = { - enable = true; - - events = [ - { - event = "before-sleep"; - command = "${lib.getExe pkgs.playerctl} pause"; - } - { - event = "before-sleep"; - command = "${pkgs.swaylock}/bin/swaylock"; - } - { - event = "lock"; - command = "${pkgs.swaylock}/bin/swaylock"; - } - ]; - - timeouts = - [ - { - timeout = 120; - command = "${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r"; - } - { - timeout = 600; - command = "${pkgs.swaylock}/bin/swaylock"; - } - ] - ++ lib.optional cfg.desktop.autoSuspend { - timeout = 600; - command = "sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'"; - } - ++ lib.optional (!cfg.desktop.autoSuspend) - { - timeout = 600; - command = "${pkgs.swaylock}/bin/swaylock"; - } - ++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable) - { - timeout = 630; - command = "${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'"; - } - ++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable) - { - timeout = 630; - command = "${swaymsg} \"output * dpms off\"' resume '${swaymsg} \"output * dpms on\""; - }; - }; - }; -} diff --git a/homeManagerModules/apps/swayosd/default.nix b/homeManagerModules/apps/swayosd/default.nix deleted file mode 100644 index 42199d3a..00000000 --- a/homeManagerModules/apps/swayosd/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - config, - lib, - ... -}: { - config = lib.mkIf config.ar.home.apps.swayosd.enable { - services.swayosd.enable = true; - }; -} diff --git a/homeManagerModules/desktop/wayland/default.nix b/homeManagerModules/desktop/wayland/default.nix index 69c48339..69cf84d3 100644 --- a/homeManagerModules/desktop/wayland/default.nix +++ b/homeManagerModules/desktop/wayland/default.nix @@ -5,14 +5,18 @@ ... }: { config = lib.mkIf (config.ar.home.desktop.hyprland.enable || config.ar.home.desktop.sway.enable) { - ar.home.apps = { - kitty.enable = lib.mkDefault true; - mako.enable = lib.mkDefault true; - rofi.enable = lib.mkDefault true; - swayidle.enable = lib.mkDefault true; - swaylock.enable = lib.mkDefault true; - swayosd.enable = lib.mkDefault true; - waybar.enable = lib.mkDefault true; + ar.home = { + apps = { + kitty.enable = lib.mkDefault true; + mako.enable = lib.mkDefault true; + rofi.enable = lib.mkDefault true; + swaylock.enable = lib.mkDefault true; + waybar.enable = lib.mkDefault true; + }; + services = { + swayidle.enable = lib.mkDefault true; + swayosd.enable = lib.mkDefault true; + }; }; dconf = { diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index a7c46852..7b0ffd84 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -62,9 +62,7 @@ in { }; rofi.enable = lib.mkEnableOption "Rofi launcher."; - swayidle.enable = lib.mkEnableOption "Swayidle idle daemon."; swaylock.enable = lib.mkEnableOption "Swaylock screen locker."; - swayosd.enable = lib.mkEnableOption "On Screen Display (OSD) for volume/brightness/etc."; thunar.enable = lib.mkOption { description = "Thunar file manager."; @@ -217,6 +215,9 @@ in { type = lib.types.str; }; }; + + swayidle.enable = lib.mkEnableOption "Swayidle idle daemon."; + swayosd.enable = lib.mkEnableOption "On Screen Display (OSD) for volume/brightness/etc."; }; theme = { diff --git a/homeManagerModules/services/default.nix b/homeManagerModules/services/default.nix index 8ab0c7dc..7fd52f95 100644 --- a/homeManagerModules/services/default.nix +++ b/homeManagerModules/services/default.nix @@ -2,5 +2,7 @@ imports = [ ./easyeffects ./mpd + ./swayidle + ./swayosd ]; }