From 25139ece89672d2f6aa73912ddaf491ecae0869c Mon Sep 17 00:00:00 2001 From: JuliusFreudenberger Date: Sat, 27 Jun 2026 12:06:46 +0200 Subject: [PATCH] Configure swaylock and swayidle --- home/sway.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/home/sway.nix b/home/sway.nix index c3b6b11..e1f8099 100644 --- a/home/sway.nix +++ b/home/sway.nix @@ -7,6 +7,7 @@ }: let modifier = "Mod4"; cfg = config.wayland.windowManager.sway; + background = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom}/share/wallpapers/simple-dark-gray/contents/images/nix-wallpaper-simple-dark-gray_bottom.png"; applications = "(D)iscord, Slac(k), (E)lement, (N)extcloud, (M)usic, (B)luetooth, (V)alent"; exit = "(l)ock, (e)xit, switch_(u)ser, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown"; @@ -43,7 +44,7 @@ in { }; output = { "*" = { - bg = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray-bottom}/share/wallpapers/simple-dark-gray/contents/images/nix-wallpaper-simple-dark-gray_bottom.png fill"; + bg = "${background} fill"; }; eDP-1 = { scale = "1"; @@ -236,6 +237,29 @@ in { ''; }; + programs.swaylock = { + enable = true; + settings = { + image = background; + }; + }; + + services.swayidle = let + swaylock = "${lib.getExe pkgs.swaylock} -f"; + switchOutput = "${pkgs.sway}/bin/swaymsg 'output * power'"; + in { + enable = true; + events = { + before-sleep = swaylock; + lock = swaylock; + after-resume = "${switchOutput} on"; + }; + timeouts = [ + { timeout = 300; command = "${switchOutput} off"; } + { timeout = 330; command = swaylock; } + ]; + }; + services.wlsunset = { enable = true; latitude = osConfig.location.latitude;