about summary refs log tree commit diff
diff options
context:
space:
mode:
-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";
+        }
+      ];
     };
+
   };
 }