feat: Add swayidle as a systemd service

fix #29
This commit is contained in:
Charlotte 🦝 Delenk 2022-03-06 10:43:01 +01:00
parent 1105e2de4a
commit f39bd3263a
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
2 changed files with 35 additions and 0 deletions

View file

@ -2,6 +2,7 @@
imports = [
./wl-clipboard.nix
./mako.nix
./swayidle.nix
];
wayland.windowManager.sway = {
enable = true;

View file

@ -0,0 +1,34 @@
{ 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" ''
${pkgs.systemctl}/bin/systemctl suspend
'';
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 = {
ExecStart = "${pkgs.swayidle}/bin/swayidle -w timeout 300 ${lock-script} timeout 305 ${screen-off-script} timeout 900 ${suspend-script} resume ${resume-script} lock ${lock-script} unlock ${unlock-script}";
};
};
}