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.
This commit is contained in:
@@ -32,7 +32,12 @@ func (y *ydotoolBackend) Available() error {
|
|||||||
return fmt.Errorf("ydotoold socket not found - ensure ydotoold is running")
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("ydotoold not responding at %s: %w", socketPath, err)
|
return fmt.Errorf("ydotoold not responding at %s: %w", socketPath, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user