Fix HID timeout/EINTR errors and relative icon paths

- Treat "timeout" and "interrupted system call" from ReadWithTimeout as
  non-fatal — hidraw on Linux returns errors instead of (0, nil) for
  both, causing false device-dead detection and reconnect loops
- Resolve icons_dir relative to the config file when the path is not
  absolute, so the service finds icons regardless of working directory
- Installer now copies bundled icons to the config dir on first install
This commit is contained in:
2026-03-15 10:36:44 -06:00
parent 84430cb84b
commit b428f4861a
3 changed files with 64 additions and 2 deletions

View File

@@ -49,5 +49,11 @@ func Load(path string) (*Config, error) {
return nil, fmt.Errorf("parse config: %w", err)
}
// Resolve relative icons_dir against the config file's directory so the
// binary works regardless of the working directory (e.g. as a systemd service).
if !filepath.IsAbs(cfg.IconsDir) {
cfg.IconsDir = filepath.Join(filepath.Dir(path), cfg.IconsDir)
}
return cfg, nil
}

View File

@@ -7,6 +7,7 @@ import (
"image"
"image/jpeg"
_ "image/png"
"strings"
"sync"
"github.com/sstallion/go-hid"
@@ -152,6 +153,12 @@ func (sd *StreamDeck) ReadButtons() ([]bool, error) {
data := make([]byte, readReportSize)
n, err := sd.dev.ReadWithTimeout(data, 250)
if err != nil {
// hidraw on Linux returns errors rather than (0, nil) for non-fatal
// conditions: timeout waiting for data, or EINTR (signal interrupted).
msg := strings.ToLower(err.Error())
if strings.Contains(msg, "timeout") || strings.Contains(msg, "interrupted") {
return nil, nil
}
return nil, err
}
if n == 0 {