From c5adf29545b553089ccf9c28b68973ce6f812c1c Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Sat, 5 Nov 2022 12:00:00 +0000 Subject: [PATCH] i3: fix reloading when there are several sockets This can happen after logout/login. Fixes #527 --- modules/services/window-managers/i3-sway/i3.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/services/window-managers/i3-sway/i3.nix b/modules/services/window-managers/i3-sway/i3.nix index 16e82d163..21044a543 100644 --- a/modules/services/window-managers/i3-sway/i3.nix +++ b/modules/services/window-managers/i3-sway/i3.nix @@ -249,10 +249,13 @@ in { xdg.configFile."i3/config" = { source = checkI3Config; onChange = '' - i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* - if [ -S $i3Socket ]; then - ${cfg.package}/bin/i3-msg -s $i3Socket reload >/dev/null - fi + # There may be several sockets after log out/log in, but the old ones + # will fail with "Connection refused". + for i3Socket in ''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.*; do + if [[ -S $i3Socket ]]; then + ${cfg.package}/bin/i3-msg -s $i3Socket reload >/dev/null |& grep -v "Connection refused" || true + fi + done ''; }; }