nixos-config/modules/home/sway-idle-lock.nix

68 lines
1.8 KiB
Nix
Raw Permalink Normal View History

{ pkgs, ... }:
with pkgs.lib.nix-rice;
let
strPalette = palette.toRgbShortHex pkgs.rice.colorPalette;
in
2025-06-28 13:00:19 -04:00
{
services.swayidle = {
enable = true;
2025-06-29 20:58:23 -04:00
systemdTarget = "graphical-session.target";
extraArgs = [ "-w" ];
2025-06-28 13:00:19 -04:00
events = [
{
event = "lock";
2025-07-04 12:47:49 -04:00
command = "${pkgs.swaylock-plugin}/bin/swaylock-plugin";
2025-06-29 20:58:23 -04:00
}
2025-06-28 13:00:19 -04:00
{
event = "after-resume";
command = "/home/emenel/.local/bin/on-unlock";
}
];
timeouts = [
{
timeout = 60;
command = "/home/emenel/.local/bin/dim-all-monitors";
2025-06-29 20:58:23 -04:00
resumeCommand = "/home/emenel/.local/bin/on-unlock";
2025-06-28 13:00:19 -04:00
}
# battery timers
{
timeout = 90;
2025-07-04 12:47:49 -04:00
command = "${pkgs.systemd}/bin/systemd-ac-power || ${pkgs.niri-unstable}/bin/niri msg action power-off-monitors && ${pkgs.systemd}/bin/loginctl lock-session";
2025-06-28 13:00:19 -04:00
}
{
timeout = 180;
command = "${pkgs.systemd}/bin/systemd-ac-power || ${pkgs.systemd}/bin/systemctl suspend";
2025-06-28 13:00:19 -04:00
}
# ac power timers
{
timeout = 180;
2025-07-04 12:47:49 -04:00
command = "${pkgs.systemd}/bin/systemd-ac-power && ${pkgs.niri-unstable}/bin/niri msg action power-off-monitors && ${pkgs.systemd}/bin/loginctl lock-session";
2025-06-28 13:00:19 -04:00
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemd-ac-power && ${pkgs.systemd}/bin/systemctl suspend";
2025-06-28 13:00:19 -04:00
}
];
};
programs.swaylock = {
enable = true;
package = pkgs.swaylock-plugin;
2025-06-28 13:00:19 -04:00
settings = {
color = "000000";
font-size = 32;
2025-06-28 13:00:19 -04:00
indicator-idle-visible = true;
indicator-radius = 350;
line-color = strPalette.normal.magenta;
2025-06-28 13:00:19 -04:00
show-failed-attempts = true;
grace = "10sec";
ignore-empty-password = true;
command = "${pkgs.wpaperd}/bin/wpaperd";
2025-06-28 13:00:19 -04:00
};
};
}