diff --git a/users/simon/modules/sway.nix b/users/simon/modules/sway.nix index f32017e..b060da8 100644 --- a/users/simon/modules/sway.nix +++ b/users/simon/modules/sway.nix @@ -213,13 +213,6 @@ lib.mkIf nixosConfig.sbruder.gui.enable { }; extraConfig = '' - # Auto lock - exec ${pkgs.swayidle}/bin/swayidle -w \ - timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \ - timeout 300 'swaymsg "output * dpms off"' \ - resume 'swaymsg "output * dpms on"' \ - before-sleep "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" - # Cursor seat seat0 xcursor_theme Adwaita @@ -239,6 +232,22 @@ lib.mkIf nixosConfig.sbruder.gui.enable { ''; }; + systemd.user.services.swayidle = { + Unit.PartOf = [ "sway-session.target" ]; + Install.WantedBy = [ "sway-session.target" ]; + + Service = { + ExecStart = '' + ${pkgs.swayidle}/bin/swayidle -w \ + timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \ + timeout 300 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" + ''; + Restart = "on-failure"; + }; + }; + # Start on tty1 programs.zsh.initExtra = '' if [[ -z $WAYLAND_DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then