Bluetooth Activation Deactivation
fishooo0815 opened this issue · comments
I have a lot of Bluetooth Devices connected to my Mac when i work on my Desk.
I want to automatic activate Bluetooth when i am on my desk. and disable when i leave the desk.
Trigger could be:
- external monitors on the dock - this would be better than charging as trigger, because sometimes i am charging on the go without dock
- connected keyboard over usb - this would be better than charging as trigger, because sometimes i am charging on the go without dock
- connected elegato dock or charging!
- or if the dock is connected the mac is charging
- not a good solution but a possible workaround - a connected harddrive
See http://www.hammerspoon.org/docs/index.html for details; here are some suggestions on where to start looking:
hs.screen.watcher
can be used to generate a callback when a monitor is added or removed... I think it's triggered whenever there is a change, so your callback would have to check which monitors are attached via hs.screen.allScreens()
and make a decision based on that.
hs.usb
and hs.usb.watcher
should be able to detect when a keyboard is attached/removed, and maybe the dock too, depending upon how it's registering itself.
hs.fs.volume
can detect when a drive is mounted or unmounted.
Currently we don't have direct support for enabling/disabling bluetooth, but Homebrew (https://brew.sh) has blueutil
which you can invoke via hs.execute
or hs.task
with the appropriate paramters.