From bcd4db175808c81825831ca778bb8f90eea383ad Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Wed, 29 Mar 2023 21:37:31 -0700 Subject: [PATCH] Configured swayidle --- modules/desktop/addons/swayidle/default.nix | 40 +++++++++++++++++++++ modules/desktop/sway/default.nix | 1 + 2 files changed, 41 insertions(+) create mode 100644 modules/desktop/addons/swayidle/default.nix diff --git a/modules/desktop/addons/swayidle/default.nix b/modules/desktop/addons/swayidle/default.nix new file mode 100644 index 0000000..a6d9b65 --- /dev/null +++ b/modules/desktop/addons/swayidle/default.nix @@ -0,0 +1,40 @@ +{ + 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 = { + 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/desktop/sway/default.nix b/modules/desktop/sway/default.nix index c973447..f93f784 100644 --- a/modules/desktop/sway/default.nix +++ b/modules/desktop/sway/default.nix @@ -31,6 +31,7 @@ in { mako.enable = true; playerctl.enable = true; rofi.enable = true; + swayidle.enable = true; swaylock.enable = true; waybar.enable = true;