Configure swaylock and swayidle

This commit is contained in:
JuliusFreudenberger 2026-06-27 12:06:46 +02:00
parent 30207ec5f0
commit 25139ece89

View file

@ -7,6 +7,7 @@
}: let }: let
modifier = "Mod4"; modifier = "Mod4";
cfg = config.wayland.windowManager.sway; 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"; 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"; exit = "(l)ock, (e)xit, switch_(u)ser, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown";
@ -43,7 +44,7 @@ in {
}; };
output = { 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 = { eDP-1 = {
scale = "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 = { services.wlsunset = {
enable = true; enable = true;
latitude = osConfig.location.latitude; latitude = osConfig.location.latitude;