From 4a5d60095a2422edff3fd06b60d5e76e79b59560 Mon Sep 17 00:00:00 2001 From: burakgizlice Date: Fri, 13 Feb 2026 23:45:43 +0300 Subject: [PATCH 1/2] fix: use SOCK_DGRAM for ydotoold socket (v1.0.4+) ydotoold v1.0.4+ uses SOCK_DGRAM (unixgram) Unix sockets instead of SOCK_STREAM. The availability check was using net.DialTimeout("unix", ...) which only supports stream sockets, causing a "protocol wrong type for socket" error on systems with newer ydotool versions. Try unixgram first, then fall back to stream for older versions. --- internal/injection/ydotool.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/injection/ydotool.go b/internal/injection/ydotool.go index 23258be..9974507 100644 --- a/internal/injection/ydotool.go +++ b/internal/injection/ydotool.go @@ -32,7 +32,12 @@ func (y *ydotoolBackend) Available() error { return fmt.Errorf("ydotoold socket not found - ensure ydotoold is running") } - conn, err := net.DialTimeout("unix", socketPath, 500*time.Millisecond) + // ydotoold v1.0.4+ uses SOCK_DGRAM (unixgram) sockets. + // Try unixgram first, then fall back to stream for older versions. + conn, err := net.Dial("unixgram", socketPath) + if err != nil { + conn, err = net.DialTimeout("unix", socketPath, 500*time.Millisecond) + } if err != nil { return fmt.Errorf("ydotoold not responding at %s: %w", socketPath, err) } From b694e58d906503c03c3bbbbee7b664d90816f9c3 Mon Sep 17 00:00:00 2001 From: burakgizlice Date: Sat, 14 Feb 2026 00:16:30 +0300 Subject: [PATCH 2/2] fix: add timeout to unixgram dial Use net.Dialer with a 500ms timeout for the unixgram dial to guard against edge cases, as suggested in review. --- internal/injection/ydotool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/injection/ydotool.go b/internal/injection/ydotool.go index 9974507..2df993f 100644 --- a/internal/injection/ydotool.go +++ b/internal/injection/ydotool.go @@ -34,7 +34,10 @@ func (y *ydotoolBackend) Available() error { // ydotoold v1.0.4+ uses SOCK_DGRAM (unixgram) sockets. // Try unixgram first, then fall back to stream for older versions. - conn, err := net.Dial("unixgram", socketPath) + // Note: unixgram dials are effectively instant (no handshake), but we + // use a dialer with a deadline to stay consistent and guard against edge cases. + dialer := net.Dialer{Timeout: 500 * time.Millisecond} + conn, err := dialer.Dial("unixgram", socketPath) if err != nil { conn, err = net.DialTimeout("unix", socketPath, 500*time.Millisecond) }