Fall back to the system Speech Dispatcher socket

When using the default Speech Dispatcher address, try the user's Unix
socket first and then /run/speech-dispatcher/speechd.sock if the user
socket is missing or refuses the connection. This allows Fenrir to use
an existing system service before attempting to autospawn a user daemon.

Keep explicit Options.Socket, SPEECHD_ADDRESS, and SPEECHD_SOCKET
settings authoritative. Do not fall back for permission errors, TCP
connections, or a canceled context. If both sockets fail, preserve the
user socket's error so autospawn continues to target the user's endpoint.

After opening the data connection, use its selected Unix socket for the
control connection and disable further fallback there. Both connections
must belong to the same Speech Dispatcher server.

Add tests for address overrides, user-first selection, missing and stale
user sockets, permission errors, and preservation of the original error
when neither socket is available.

Validation:
- go test ./internal/speech -count=1 (GOPROXY=off): passed
- git diff --check: passed
- gofmt -l on all five changed Go files: no output

Live audible speech and physical keyboard behavior were not verified
as part of this commit.
This commit is contained in:
deedra committed 2026-10-28 10:44:54 -07:00
1 parent 55d550583c
commit 92bf3025c5
5 files changed
+110 -6

No files matched your search

+5
View File
@@ -88,3 +88,8 @@ func parse_server_address(address string) (serverAddress, error) {
return serverAddress{}, fmt.Errorf("unsupported Speech Dispatcher address %q", address)
}
}
// Explicit settings select exactly one server; only defaults use fallback.
func automatic_server_address(socket string) bool {
return socket == "" && os.Getenv("SPEECHD_ADDRESS") == "" && os.Getenv("SPEECHD_SOCKET") == ""
}