From 04bac349d585c9df38d78e0285b780a140dc74a4 Mon Sep 17 00:00:00 2001 From: 9p4 Date: Sat, 11 Nov 2023 19:13:38 -0500 Subject: [PATCH] swayidle: always restart systemd unit on failure Occasionally, swayidle crashes with a failure to connect to the Wayland session. Ideally, swayidle should automatically restart instead of leaving the system in a vulnerable state. (cherry picked from commit 50e582b9f91e409ffd2e134017445d376659b32e) --- modules/services/swayidle.nix | 1 + tests/modules/services/swayidle/basic-configuration.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/services/swayidle.nix b/modules/services/swayidle.nix index 6e8b55cb..7d1fa455 100644 --- a/modules/services/swayidle.nix +++ b/modules/services/swayidle.nix @@ -121,6 +121,7 @@ in { Service = { Type = "simple"; + Restart = "always"; # swayidle executes commands using "sh -c", so the PATH needs to contain a shell. Environment = [ "PATH=${makeBinPath [ pkgs.bash ]}" ]; ExecStart = diff --git a/tests/modules/services/swayidle/basic-configuration.nix b/tests/modules/services/swayidle/basic-configuration.nix index caa06ae1..96d98320 100644 --- a/tests/modules/services/swayidle/basic-configuration.nix +++ b/tests/modules/services/swayidle/basic-configuration.nix @@ -46,6 +46,7 @@ assertFileExists $serviceFile assertFileRegex $serviceFile 'ExecStart=.*/bin/swayidle ${expectedArgs}' + assertFileRegex $serviceFile 'Restart=always' assertFileRegex $serviceFile 'Environment=.*PATH=${ lib.makeBinPath [ pkgs.bash ] }'