From 8a160f01abe97e86a89f0312ef4046ca7656f207 Mon Sep 17 00:00:00 2001 From: John Axel Eriksson Date: Wed, 23 Sep 2020 13:10:58 +0200 Subject: [PATCH] sway: fix onChange for sway config when sway isn't running (#1506) `pgrep -x somecommand` exits with a non-zero status if it finds no process running with the given name. When using home-manager as a NixOS module, on boot (when sway isn't running) this script would fail and then fail the unit since it seems the onChange scripts are running with the -e switch. This change ensures we're always returning a 0 exit status where we attempt to get the pid of sway - we're only interested in either the pid or an empty string, the exit status isn't important. --- modules/services/window-managers/i3-sway/sway.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 8f0ee6081..14d82d267 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -396,7 +396,7 @@ in { xdg.configFile."sway/config" = { source = configFile; onChange = '' - swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway).sock + swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock if [ -S $swaySocket ]; then echo "Reloading sway" $DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload