Skip to content

Fall back to plain foot when no foot server is running - #229

Open
kacperpaczos wants to merge 1 commit into
Dvlv:masterfrom
kacperpaczos:fix/foot-server-fallback
Open

Fall back to plain foot when no foot server is running#229
kacperpaczos wants to merge 1 commit into
Dvlv:masterfrom
kacperpaczos:fix/foot-server-fallback

Conversation

@kacperpaczos

Copy link
Copy Markdown
Contributor

Fixes #228

The Foot entry in the supported-terminals table always launches footclient, but footclient is only a thin client: it needs a foot --server listening on its socket, and exits with code 220 — no terminal window — when there is none. So choosing Foot without a running server made every terminal action silently do nothing.

This mirrors footclient(1)'s socket lookup — $XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock, then $XDG_RUNTIME_DIR/foot.sock when $WAYLAND_DISPLAY is unset, then /tmp/foot.sock — and launches plain foot instead when no socket exists (and foot is installed; otherwise the choice is left as it was). With a live server footclient is used exactly as before, so server users keep the fast client. The swap is drop-in: foot and footclient both take the command positionally, and both accept-and-ignore -e for xterm compatibility (foot(1), footclient(1)), which is the separator this table already uses.

In the Flatpak the check asks the host (flatpak-spawn --host test -e), because the sandbox mounts its own runtime dir where a host-side server's socket is not visible — and the terminal itself is spawned on the host anyway.

One assumption worth flagging: the check is "does the default socket path exist", not "can it be connected to". A stale socket left behind by a crashed server still picks footclient, and a server started with a custom --server <path> socket is missed — in that case plain foot still opens a working terminal, just not through the server. I have asked the reporter in #228 whether either case applies to their setup.

Testing

A unit test pins the socket lookup order against footclient(1). End to end, with stub foot/footclient binaries that log their invocations, an isolated settings backend with Foot selected, and XDG_RUNTIME_DIR/WAYLAND_DISPLAY pointed at a scratch directory, clicking Open Terminal gives:

# server socket present
footclient -e distrobox enter fakebox
# socket removed, same session
foot -e distrobox enter fakebox

The flatpak-sandbox branch of the check is the one part I could not exercise end to end here (native install); it degrades to the plain-foot fallback if the host query fails.

The Foot entry in the supported-terminals table launches footclient,
which is only a thin client: it needs a foot --server listening on its
socket and exits with code 220 - no terminal window - when there is
none. Mirror footclient(1)'s socket lookup (foot-$WAYLAND_DISPLAY.sock,
foot.sock under $XDG_RUNTIME_DIR, /tmp/foot.sock) and hand back plain
foot when no server socket exists. foot and footclient take the command
positionally and both ignore -e, so the swap is drop-in.

Fixes the Foot preference silently doing nothing for users who do not
run a foot server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Foot terminal choice always opens footclient even if a server isn't active

1 participant