Files
nixconfig/packages/eww-ensure-daemon/default.nix
T
2026-07-19 23:11:43 +02:00

20 lines
779 B
Nix

{ lib, writeShellScriptBin, eww, systemd }:
# `eww open` silently becomes a NEW daemon when it can't reach the socket,
# rebinding the same socket path and orphaning the previous daemon. The old
# daemon keeps rendering its layer-shell surfaces but no longer answers any
# `eww close` — that is the "zombie panel I can't close" / "bar opened twice".
# Every open path must go through here first, so the socket is always live
# before a client touches it and no client ever self-daemonizes.
writeShellScriptBin "eww-ensure-daemon" ''
${lib.getExe eww} ping >/dev/null 2>&1 && exit 0
${systemd}/bin/systemctl --user start eww.service >/dev/null 2>&1 || true
for _ in $(seq 1 100); do
${lib.getExe eww} ping >/dev/null 2>&1 && exit 0
sleep 0.1
done
exit 1
''