2022-03-06 09:43:01 +00:00
|
|
|
{ pkgs, ... }:
|
|
|
|
let
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
systemd.user.services.swayidle = {
|
|
|
|
Unit = {
|
|
|
|
Description = "swayidle";
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
Install = {
|
|
|
|
WantedBy = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
Service = {
|
2022-04-30 09:36:04 +00:00
|
|
|
ExecStart = "${pkgs.swayidle}/bin/swayidle -w timeout 300 ${lock-script} timeout 305 ${screen-off-script} resume ${resume-script} before-sleep ${lock-script} timeout 900 ${suspend-script} lock ${lock-script} unlock ${unlock-script}";
|
2022-03-06 09:43:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|