sway: Manage swayidle with systemd

This commit is contained in:
Simon Bruder 2021-03-02 09:31:53 +01:00
parent d8f75f167a
commit e17aa4bc6b
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -213,13 +213,6 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
}; };
extraConfig = '' 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 # Cursor
seat seat0 xcursor_theme Adwaita 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 # Start on tty1
programs.zsh.initExtra = '' programs.zsh.initExtra = ''
if [[ -z $WAYLAND_DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then if [[ -z $WAYLAND_DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then