Created
October 7, 2018 15:41
-
-
Save rkoch/ff989634cf5352ec87f37649fcb053c9 to your computer and use it in GitHub Desktop.
Hammerspoon Auto Reload Config
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
#!/usr/bin/env bash | |
log () { | |
echo "LOG[hammerspoon]: $1" | |
} | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
DEFAULTS=/usr/bin/defaults | |
BUDDY=/usr/libexec/PlistBuddy | |
DOMAIN="org.hammerspoon.Hammerspoon" | |
log 'Starting and stopping Hammerspoon for initial preferences.' | |
open /Applications/Hammerspoon.app | |
sleep 2 | |
killall Hammerspoon | |
sleep 2 | |
log 'Updating default settings' | |
$DEFAULTS write $DOMAIN MJConfigFile "~/.config/hammerspoon/init.lua" | |
$DEFAULTS write $DOMAIN MJShowDockIconKey -bool false | |
$DEFAULTS write $DOMAIN MJShowMenuIconKey -bool false | |
$DEFAULTS write $DOMAIN MJSkipDockMenuIconProblemAlertKey -bool true | |
log 'Linking configuration' | |
ln -s $DIR ~/.config/hammerspoon |
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
-- Toogle Emacs window using alt-e | |
local function togglEmacs() | |
local e = hs.application.get('Emacs') | |
if e then | |
if e:isFrontmost() then | |
e:hide() | |
else | |
e:activate() | |
end | |
end | |
end | |
hs.hotkey.bind({"alt"}, "e", togglEmacs) |
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
-- lol | |
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function() | |
hs.notify.new({title="Hammerspoon", informativeText="Hello World"}):send() | |
end) |
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
-- Reload config automatically | |
local configFileWatcher | |
function reloadConfig() | |
configFileWatcher:stop() | |
configFileWatcher = nil | |
hs.reload() | |
end | |
configFileWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.config/hammerspoon/", reloadConfig) | |
configFileWatcher:start() | |
-- Load local modules | |
require("hello-world") | |
require("emacs") | |
-- Load Spoons | |
-- | |
-- Finally, show a notification that we finished loading the config | |
hs.notify.new( {title='Hammerspoon', subTitle='Configuration loaded'} ):send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment