I've searched a number of sites but thought I'd post it here. I'm want to a detect certain usb device (external camera) that is actively being used by an app on a mac.
My search has led me through looking at the system events log to see if there is a ProductID indicator logged. The device is plugged into the same so researching on how to check any output from the port.
Anyone thoughts on additional ways to tackle this? am i in the right place> appreciate any feedback
So for I have a bash script that detects the usb devices on a mac
# USB Devices detected
log "List of USB Devices "
log ""
USB=`ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*'`
log "$USB"
The following usb devices detected and written to a log file:
AppleUSBEHCI Root Hub Simulation
IOUSBHostDevice
IOUSBHostDevice
Apple Internal Keyboard / Trackpad
IR Receiver
BRCM20702 Hub
Bluetooth USB Host Controller
Keyboard Hub
Apple Keyboard
AppleUSBXHCI Root Hub Simulation
You can get this information with the macOS command:
system_profiler
See summary man page here:
root# system_profiler -usage
Usage: system_profiler [-listDataTypes]
system_profiler [-xml] [-timeout n] [-detailLevel n]
system_profiler [-xml] [-timeout n] [dataType1 ... dataTypeN]
-detailLevel n specifies the level of detail for the report
mini = short report (contains no identifying or personal information)
basic = basic hardware and network information
full = all available information
-listDataTypes lists all the available datatypes
-xml generates xml output instead of plain text
if redirected to a file with the extension ".spx"
the file can be opened in System Profiler.app
-timeout specifies the maximum time to spend gathering information
the default is 180 seconds, 0 means no timeout
Redirect stderr to /dev/null to suppress progress and error messages.
Examples:
system_profiler
Generates a text report with the standard detail level.
system_profiler -detailLevel mini
Generates a short report without identifying/personal information.
system_profiler -listDataTypes
Shows a list of the available data types.
system_profiler SPSoftwareDataType SPNetworkDataType
Generates a text report containing only software and network data.
system_profiler -xml >MySystem.spx
Creates a XML file which can be opened by System Profiler.app
Neo, thanks for the info. This really will save me plenty of time and help with monitoring some usb devices. It help me to know if external device is no longer active