about summary refs log tree commit diff
path: root/home/wm/swaylock/default.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
commit2aa3e62136109c5c4762e951525d68aff3e1ac5a (patch)
tree0f508cad82717ac70c7da5fd402c9555ce9166d1 /home/wm/swaylock/default.nix
parenthome: fix for yt-dlp configuration (diff)
downloadworld-2aa3e62136109c5c4762e951525d68aff3e1ac5a.tar.gz
home: add more configurations for home-manager
Diffstat (limited to '')
-rw-r--r--home/wm/swaylock/default.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/home/wm/swaylock/default.nix b/home/wm/swaylock/default.nix
new file mode 100644
index 0000000..3df802a
--- /dev/null
+++ b/home/wm/swaylock/default.nix
@@ -0,0 +1,27 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+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";
+      };
+    };
+  };
+}