sway: Manage swayidle with systemd

pull/48/head
Simon Bruder 2021-03-02 09:31:53 +01:00
parent d8f75f167a
commit e17aa4bc6b
Signed by: simon
GPG Key ID: 8D3C82F9F309F8EC
1 changed files with 16 additions and 7 deletions

View File

@ -213,13 +213,6 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
};
extraConfig = ''
# Auto lock
exec ${pkgs.swayidle}/bin/swayidle -w \
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}"
# Cursor
seat seat0 xcursor_theme Adwaita
@ -239,6 +232,22 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
'';
};
systemd.user.services.swayidle = {
Unit.PartOf = [ "sway-session.target" ];
Install.WantedBy = [ "sway-session.target" ];
Service = {
ExecStart = ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}"
'';
Restart = "on-failure";
};
};
# Start on tty1
programs.zsh.initExtra = ''
if [[ -z $WAYLAND_DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then