-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
22 lines (19 loc) · 822 Bytes
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Avoid automatically setting a bluetooth audio input device
lastSetDeviceTime = os.time()
lastInputDevice = nil
function audioDeviceChanged(arg)
if arg == 'dev#' or arg == 'dOut' then
lastSetDeviceTime = os.time()
elseif arg == 'dIn ' and os.time() - lastSetDeviceTime < 2 then
inputDevice = hs.audiodevice.defaultInputDevice()
if inputDevice:transportType() == 'Bluetooth' then
internalMic = lastInputDevice or hs.audiodevice.findInputByName('Built-in Microphone')
internalMic:setDefaultInputDevice()
end
end
if hs.audiodevice.defaultInputDevice():transportType() ~= 'Bluetooth' then
lastInputDevice = hs.audiodevice.defaultInputDevice()
end
end
hs.audiodevice.watcher.setCallback(audioDeviceChanged)
hs.audiodevice.watcher.start()