diff --git a/systemd/streamdeck-go-watchdog.sh b/systemd/streamdeck-go-watchdog.sh index b00924e..8791626 100644 --- a/systemd/streamdeck-go-watchdog.sh +++ b/systemd/streamdeck-go-watchdog.sh @@ -51,20 +51,23 @@ current_addr() { ' ;; Darwin) - # system_profiler entry per device: - # Stream Deck XL: - # Product ID: 0x00ba - # Vendor ID: 0x0fd9 (Elgato ...) - # ... - # Location ID: 0x14140000 / 5 - # The trailing "/ N" is the bus address — it changes on replug. - system_profiler SPUSBDataType 2>/dev/null | awk -v pids="$PIDS_RE" ' - /^[[:space:]]*Product ID:/ { pid = $3 } - /^[[:space:]]*Vendor ID:/ { vid = $3 } - /^[[:space:]]*Location ID:/ { - sub(/^[[:space:]]*Location ID:[[:space:]]*/, "") - if (vid == "0x0fd9" && pid ~ ("^0x(" pids ")$")) { - print + # ioreg is the reliable source on macOS — system_profiler SPUSBDataType + # silently omits the deck on some machines, and its "Location ID: X / N" + # trailing bus number flaps spuriously without an actual replug. + # + # sessionID is unique per USB enumeration session: stable while the + # device stays plugged in, changes on every replug. Exactly what we want. + # + # Elgato vendor in decimal: 4057 (0x0fd9). + # Stream Deck product IDs in decimal: 186 (0x00ba), 108 (0x006c), 109 (0x006d). + ioreg -p IOUSB -l -w 0 2>/dev/null | awk ' + /