File tree Expand file tree Collapse file tree
pkg/macos-hammerspoon/.hammerspoon Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ -- Auto connect to speak when connected to monitor
2+ --
3+ -- Reference: https://www.hammerspoon.org/go/#usbevents
4+
5+ local monitorVendorID = 32903
6+ local speakerBluetoothAddress = " 74-ca-60-56-7a-d4"
7+
8+ local BLUEUTIL = " /opt/homebrew/bin/blueutil"
9+
10+ local function usbDeviceCallback (data )
11+ if data .eventType == " added" and data .vendorID == monitorVendorID then
12+ -- print("USB event:", hs.inspect(data))
13+ print (" Dell monitor connected, start connecting to speak" )
14+ local ok , out = hs .execute (BLUEUTIL .. " --connect " .. speakerBluetoothAddress )
15+ if not ok then
16+ print (" Failed to connect to speak:" , out )
17+ else
18+ print (" Successfully connected to speak" )
19+ end
20+ end
21+ end
22+
23+ UsbWatcher = hs .usb .watcher .new (usbDeviceCallback )
24+ UsbWatcher :start ()
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ spoon.ReloadConfiguration:start()
2020-- Auto switch input method
2121require (' auto_ime' )
2222
23+ -- Auto connect to speak
24+ require (' auto_speaker_connect' )
25+
2326-- Hotkeys
2427require (' hotkeys' )
2528
You can’t perform that action at this time.
0 commit comments