about summary refs log tree commit diff
path: root/home/wm
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-01-11 17:24:18 -0800
committerFranck Cuny <franck@fcuny.net>2023-01-11 17:24:18 -0800
commit8218f499e074ce4b642da9f79165cd2a3c369e21 (patch)
treec64995160e705b81378e2824c0f83edc667b86b8 /home/wm
parentbump flakes (diff)
downloadworld-8218f499e074ce4b642da9f79165cd2a3c369e21.tar.gz
ref(home/swayidle): configure it using upstream module
Diffstat (limited to 'home/wm')
-rw-r--r--home/wm/swaylock/default.nix42
1 files changed, 24 insertions, 18 deletions
diff --git a/home/wm/swaylock/default.nix b/home/wm/swaylock/default.nix
index 803a7c3..a22d548 100644
--- a/home/wm/swaylock/default.nix
+++ b/home/wm/swaylock/default.nix
@@ -5,24 +5,30 @@ in
   config = lib.mkIf isEnabled {
     xdg.configFile."swaylock/config" = { source = ./config; };
 
-    # https://github.com/nix-community/home-manager/pull/2610
-    # won't be needed for ever
-    systemd.user.services.swayidle = {
-      Unit.PartOf = [ "sway-session.target" ];
-      Install.WantedBy = [ "sway-session.target" ];
-
-      Service = {
-        Environment =
-          "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
-        ExecStart = ''
-          ${pkgs.swayidle}/bin/swayidle -w \
-              timeout 300 "${pkgs.swaylock}/bin/swaylock" \
-              timeout 300 'swaymsg "output * dpms off"' \
-                  resume 'swaymsg "output * dpms on"' \
-              before-sleep "${pkgs.swaylock}/bin/swaylock"
-        '';
-        Restart = "on-failure";
-      };
+    services.swayidle = {
+      enable = true;
+      events = [
+        {
+          event = "before-sleep";
+          command = "${pkgs.swaylock}/bin/swaylock -fF";
+        }
+        {
+          event = "lock";
+          command = "${pkgs.swaylock}/bin/swaylock -fF";
+        }
+      ];
+      timeouts = [
+        {
+          timeout = 300;
+          command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
+          resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";
+        }
+        {
+          timeout = 310;
+          command = "${pkgs.systemd}/bin/loginctl lock-session";
+        }
+      ];
     };
+
   };
 }