Device attach or detach
Runs the macro when a USB device is plugged in or unplugged.
A device is plugged in or removed
Keyboard Maestro: USBDevice
Details #
Fires when a USB device attaches or detaches. id is compared, not case sensitive, with each name the device reports: its product name (for example Keychron K2), its vendor and product ids in lower-case hex as vvvv:pppp (for example 05ac:024f), and its serial number. Any one of them matching is enough.
Devices that are already plugged in when Switchboard starts do not fire.
{{triggerValue}} is empty.
Matching. With match left out (or is), id must equal one of those names. With contains, it only has to appear inside one of them.
Bluetooth. transport accepts bluetooth, but only USB devices produce events today. A bluetooth trigger saves and imports but does not fire.
Secure input does not affect this trigger.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
event | one of | Yes | attach detach | attach or detach. |
id | text | Yes | Product name, vid:pid or serial number. | |
transport | one of | Yes | usb bluetooth | usb or bluetooth (see above). |
match | one of | is contains | is (the default, the whole name) or contains (part of a name). |
Every trigger also takes Limits: a cooldown, the first time each day, every nth time, twice within seconds, a chance, only while you are at the Mac, on one Mac, or in a State. See Limits on any trigger.
Examples #
- USB device “05ac:024f” is attached
- Show “External keyboard connected”
Gotchas #
A hub or dock can attach several devices at once. Each fires on its own.
Not fired reasons:
disabled,groupOff,scope,paused,conditionFalse.