macOS watchdog: detect deck via ioreg sessionID
system_profiler SPUSBDataType was silently omitting the deck on some Macs (watchdog exited early, never restarted anything) and, when it did report, the trailing bus number in "Location ID: X / N" flapped without an actual replug — causing spurious restarts. ioreg sees the device reliably and sessionID changes only on real re-enumeration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,20 +51,23 @@ current_addr() {
|
|||||||
'
|
'
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
# system_profiler entry per device:
|
# ioreg is the reliable source on macOS — system_profiler SPUSBDataType
|
||||||
# Stream Deck XL:
|
# silently omits the deck on some machines, and its "Location ID: X / N"
|
||||||
# Product ID: 0x00ba
|
# trailing bus number flaps spuriously without an actual replug.
|
||||||
# Vendor ID: 0x0fd9 (Elgato ...)
|
#
|
||||||
# ...
|
# sessionID is unique per USB enumeration session: stable while the
|
||||||
# Location ID: 0x14140000 / 5
|
# device stays plugged in, changes on every replug. Exactly what we want.
|
||||||
# The trailing "/ N" is the bus address — it changes on replug.
|
#
|
||||||
system_profiler SPUSBDataType 2>/dev/null | awk -v pids="$PIDS_RE" '
|
# Elgato vendor in decimal: 4057 (0x0fd9).
|
||||||
/^[[:space:]]*Product ID:/ { pid = $3 }
|
# Stream Deck product IDs in decimal: 186 (0x00ba), 108 (0x006c), 109 (0x006d).
|
||||||
/^[[:space:]]*Vendor ID:/ { vid = $3 }
|
ioreg -p IOUSB -l -w 0 2>/dev/null | awk '
|
||||||
/^[[:space:]]*Location ID:/ {
|
/<class IOUSBHostDevice/ { vid=""; pid=""; sid="" }
|
||||||
sub(/^[[:space:]]*Location ID:[[:space:]]*/, "")
|
/"idVendor"/ { vid=$NF }
|
||||||
if (vid == "0x0fd9" && pid ~ ("^0x(" pids ")$")) {
|
/"idProduct"/ { pid=$NF }
|
||||||
print
|
/"sessionID"/ { sid=$NF }
|
||||||
|
/}/ {
|
||||||
|
if (vid == "4057" && (pid == "186" || pid == "108" || pid == "109") && sid != "") {
|
||||||
|
print sid
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user