2024-08-02 14:43:01 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.ar.home;
|
|
|
|
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
|
|
|
|
swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg";
|
|
|
|
in {
|
2024-08-02 14:49:18 -04:00
|
|
|
config = lib.mkIf cfg.services.swayidle.enable {
|
2024-08-02 14:43:01 -04:00
|
|
|
services.swayidle = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
events = [
|
|
|
|
{
|
|
|
|
event = "before-sleep";
|
|
|
|
command = "${lib.getExe pkgs.playerctl} pause";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "before-sleep";
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "lock";
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
timeouts =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
timeout = 120;
|
2024-08-02 15:46:16 -04:00
|
|
|
command = "${lib.getExe pkgs.brightnessctl} -s set 10";
|
|
|
|
resumeCommand = "${lib.getExe pkgs.brightnessctl} -r";
|
2024-08-02 14:43:01 -04:00
|
|
|
}
|
|
|
|
{
|
|
|
|
timeout = 600;
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
++ lib.optional cfg.desktop.autoSuspend {
|
|
|
|
timeout = 600;
|
2024-08-02 16:17:36 -04:00
|
|
|
command = "${lib.getExe' pkgs.systemd "systemctl"} suspend";
|
2024-08-02 14:43:01 -04:00
|
|
|
}
|
|
|
|
++ lib.optional (!cfg.desktop.autoSuspend)
|
|
|
|
{
|
|
|
|
timeout = 600;
|
|
|
|
command = "${pkgs.swaylock}/bin/swaylock";
|
|
|
|
}
|
|
|
|
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable)
|
|
|
|
{
|
|
|
|
timeout = 630;
|
2024-08-02 15:46:16 -04:00
|
|
|
command = "${hyprctl} dispatch dpms off";
|
|
|
|
resumeCommand = "${hyprctl} dispatch dpms on";
|
2024-08-02 14:43:01 -04:00
|
|
|
}
|
|
|
|
++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable)
|
|
|
|
{
|
|
|
|
timeout = 630;
|
2024-08-02 15:46:16 -04:00
|
|
|
command = "${swaymsg} \"output * dpms off\"";
|
|
|
|
resumeCommand = "${swaymsg} \"output * dpms on\"";
|
2024-08-02 14:43:01 -04:00
|
|
|
};
|
|
|
|
};
|
2024-08-02 15:40:50 -04:00
|
|
|
|
2024-08-02 16:31:15 -04:00
|
|
|
systemd.user.services.swayidle = {
|
|
|
|
Install.WantedBy = lib.mkForce ["hyprland-session.target" "sway-session.target"];
|
|
|
|
Service = {
|
|
|
|
Restart = lib.mkForce "on-failure";
|
|
|
|
RestartSec = 5;
|
|
|
|
};
|
|
|
|
};
|
2024-08-02 14:43:01 -04:00
|
|
|
};
|
|
|
|
}
|