19 Sep 2016
Automate your macOS with Hammerspoon
Posted on September 19, 2016
I’ve been using macOS for about 8 years and as a dual monitor user there was always a very annoying problem which I could never find a perfect solution for. Every time I connected or disconnected my second monitor from my MacBook, macOS messed up the window positions.
Then I discovered Hammerspoon and was not only able to fix this problem but also able to automate a lot of cool things and I was also able to replace HardwareGrowler with it.
My configuration is a available at github and provides the following features:
- Notifications for hardware events (USB, battery, WiFi, volumes)
- Window layout for single and dual monitor setups
- Connect or disconnect Bluetooth when the second monitor is plugged or unplugged (blueutil must be installed)
- growlnotify replacement:
hammerspoon://notify?title=...&subtitle=...&info=...
- Open new Chrome window for development:
hammerspoon://devopen?url=http://....
This configuration is work in progress and there will be more features in the future.
Installation
git clone https://github.com/code2k/.hammerspoon.git ~/.hammerspoon
cd ~/.hammerspoon
cp example-config.lua config.lua
Then edit config.lua
as needed.