2022-06-12 15:39:15 +00:00
|
|
|
{pkgs, ...}: let
|
2022-03-06 09:43:01 +00:00
|
|
|
lock-script = pkgs.writeScript "suspend" ''
|
|
|
|
${pkgs.swaylock}/bin/swaylock -f -c 000000
|
|
|
|
${pkgs.mpc-cli}/bin/mpc pause
|
|
|
|
'';
|
|
|
|
screen-off-script = pkgs.writeScript "screenOff" ''
|
|
|
|
${pkgs.sway}/bin/swaymsg "output * dpms off"
|
|
|
|
'';
|
|
|
|
suspend-script = pkgs.writeScript "suspend" ''
|
2022-03-06 09:46:02 +00:00
|
|
|
${pkgs.systemd}/bin/systemctl suspend
|
2022-03-06 09:43:01 +00:00
|
|
|
'';
|
|
|
|
resume-script = pkgs.writeScript "resume" ''
|
|
|
|
${pkgs.sway}/bin/swaymsg "output * dpms on"
|
|
|
|
'';
|
|
|
|
unlock-script = pkgs.writeScript "unlock" ''
|
|
|
|
${pkgs.procps}/bin/pkill swaylock
|
|
|
|
${pkgs.mpc-cli}/bin/mpc play
|
|
|
|
'';
|
2022-06-12 15:39:15 +00:00
|
|
|
in {
|
2023-01-01 11:44:43 +00:00
|
|
|
services.swayidle = {
|
|
|
|
enable = true;
|
|
|
|
events = [
|
2023-01-01 13:28:25 +00:00
|
|
|
{
|
|
|
|
event = "before-sleep";
|
|
|
|
command = "${lock-script}";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "lock";
|
|
|
|
command = "${lock-script}";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
event = "unlock";
|
|
|
|
command = "${unlock-script}";
|
|
|
|
}
|
2023-01-01 11:44:43 +00:00
|
|
|
];
|
|
|
|
timeouts = [
|
2023-01-01 13:28:25 +00:00
|
|
|
{
|
|
|
|
timeout = 300;
|
|
|
|
command = "${lock-script}";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
timeout = 305;
|
|
|
|
command = "${screen-off-script}";
|
2023-01-01 13:38:29 +00:00
|
|
|
resumeCommand = "${resume-script}";
|
2023-01-01 13:28:25 +00:00
|
|
|
}
|
2023-05-04 12:22:55 +00:00
|
|
|
#{
|
|
|
|
# timeout = 900;
|
|
|
|
# command = "${suspend-script}";
|
|
|
|
#}
|
2023-01-01 11:44:43 +00:00
|
|
|
];
|
2022-03-06 09:43:01 +00:00
|
|
|
};
|
|
|
|
}
|