From 0862244fd211881bd3ea5d4f819acb34e6d928bb Mon Sep 17 00:00:00 2001 From: alejandro-angulo Date: Sat, 3 Aug 2024 08:15:19 -0700 Subject: [PATCH] Converted swayidle to a home module --- homes/x86_64-linux/alejandro/default.nix | 5 ++- modules/home/services/swayidle/default.nix | 40 ++++++++++++++++++ .../nixos/desktop/addons/swayidle/default.nix | 41 ------------------- modules/nixos/desktop/sway/default.nix | 1 - 4 files changed, 43 insertions(+), 44 deletions(-) create mode 100644 modules/home/services/swayidle/default.nix delete mode 100644 modules/nixos/desktop/addons/swayidle/default.nix diff --git a/homes/x86_64-linux/alejandro/default.nix b/homes/x86_64-linux/alejandro/default.nix index 65dc2cb..61e2797 100644 --- a/homes/x86_64-linux/alejandro/default.nix +++ b/homes/x86_64-linux/alejandro/default.nix @@ -7,7 +7,7 @@ namespace, ... }: { - aa = { + ${namespace} = { apps = { bat.enable = true; btop.enable = true; @@ -30,8 +30,9 @@ }; services = { - swaync.enable = true; playerctld.enable = true; + swayidle.enable = true; + swaync.enable = true; }; }; } diff --git a/modules/home/services/swayidle/default.nix b/modules/home/services/swayidle/default.nix new file mode 100644 index 0000000..3030f89 --- /dev/null +++ b/modules/home/services/swayidle/default.nix @@ -0,0 +1,40 @@ +{ + config, + pkgs, + lib, + namespace, + ... +}: let + inherit (lib) mkIf mkEnableOption; + + cfg = config.${namespace}.services.swayidle; +in { + options.${namespace}.services.swayidle = { + enable = mkEnableOption "swayidle"; + }; + + config = mkIf cfg.enable { + home.packages = [pkgs.swayidle]; + + services.swayidle = { + enable = true; + timeouts = [ + { + timeout = 300; + command = "${pkgs.swaylock}/bin/swaylock"; + } + { + timeout = 600; + command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'"; + resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; + } + ]; + events = [ + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock"; + } + ]; + }; + }; +} diff --git a/modules/nixos/desktop/addons/swayidle/default.nix b/modules/nixos/desktop/addons/swayidle/default.nix deleted file mode 100644 index 28cee0e..0000000 --- a/modules/nixos/desktop/addons/swayidle/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - options, - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.aa.desktop.addons.swayidle; -in { - options.aa.desktop.addons.swayidle = with types; { - enable = mkEnableOption "swayidle"; - }; - - config = mkIf cfg.enable { - environment.systemPackages = with pkgs; [swayidle]; - - aa.home.extraOptions = { - services.swayidle = { - enable = true; - timeouts = [ - { - timeout = 300; - command = "${pkgs.swaylock}/bin/swaylock"; - } - { - timeout = 600; - command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'"; - resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'"; - } - ]; - events = [ - { - event = "before-sleep"; - command = "${pkgs.swaylock}/bin/swaylock"; - } - ]; - }; - }; - }; -} diff --git a/modules/nixos/desktop/sway/default.nix b/modules/nixos/desktop/sway/default.nix index b857932..53c5c04 100644 --- a/modules/nixos/desktop/sway/default.nix +++ b/modules/nixos/desktop/sway/default.nix @@ -38,7 +38,6 @@ in { aa.desktop.addons = { alacritty.enable = true; gammastep.enable = true; - swayidle.enable = true; # TODO # light