Open/close apps or run an arbitrary function when a USB device is connected/disconnected.
Example configuration (using SpoonInstall.spoon):
function toggleKeyboardLayout(x)
if x then
hs.keycodes.setLayout("U.S.")
else
hs.keycodes.setLayout("Colemak")
end
end
spoonInstall:andUse(
"USBDeviceActions",
{
config = {
devices = {
ScanSnapiX500EE = { apps = { "ScanSnap Manager Evernote Edition" } },
Planck = { fn = toggleKeyboardLayout },
["Corne Keyboard (crkbd)"] = { fn = toggleKeyboardLayout }
}
},
start = true
}
)
Signature | USBDeviceActions.devices (Table) |
---|---|
Type | Variable |
Description | A table where the keys should correspond to |
Notes |
Example:
|
Source | Source/USBDeviceActions.spoon/init.lua line 87 |
Signature | USBDeviceActions:init() -> Self |
---|---|
Type | Method |
Description | Creates an |
Parameters |
|
Returns |
|
Source | Source/USBDeviceActions.spoon/init.lua line 103 |
Signature | USBDeviceActions:start() -> Self |
---|---|
Type | Method |
Description | Starts the |
Parameters |
|
Returns |
|
Source | Source/USBDeviceActions.spoon/init.lua line 118 |
Signature | USBDeviceActions:stop() -> Self |
---|---|
Type | Method |
Description | Stops the |
Parameters |
|
Returns |
|
Source | Source/USBDeviceActions.spoon/init.lua line 132 |