Last active
December 10, 2020 00:55
-
-
Save ayarse/9528005ae636523ed2f574b9e01e1999 to your computer and use it in GitHub Desktop.
My QCY bluetooth headphones keep connecting to my mbp in Slave mode for some reason macOS has issues playing audio when in slave mode. Once disconnected the device reconnects in Master mode. This Hammerspoon script watches audio device events and uses blueutil (toy/blueutil) to quickly disconnect and reconnect the device if its in slave mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hs.audiodevice.watcher.setCallback(function(evt) | |
if evt == "sOut" or evt == "dOut" then | |
hs.eventtap.keyStroke({}, 'F8') | |
end | |
qcyMac = "00-00-00-00-00-00" | |
devices = hs.execute("/usr/local/bin/blueutil --paired | grep -i qcy | grep -i slave"); | |
if(string.len(devices) > 0) then | |
hs.execute("/usr/local/bin/blueutil --disconnect " .. qcyMac) | |
hs.execute("/usr/local/bin/blueutil --connect " .. qcyMac) | |
end | |
end) | |
hs.audiodevice.watcher.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment