summaryrefslogtreecommitdiffstats
path: root/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua
diff options
context:
space:
mode:
authorJesse Luehrs <doy@stripe.com>2018-04-04 14:44:25 -0700
committerJesse Luehrs <doy@tozt.net>2018-04-06 16:27:41 -0700
commitabfbd65725ba45d0b7d17eca114574ed0be4de3c (patch)
tree4b5039e6c4ef986b6f546b615b7bfc03d9011342 /hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua
parent54053d2dadfd5ba67127c636a3eb4c0f7cff5ef9 (diff)
downloadconf-abfbd65725ba45d0b7d17eca114574ed0be4de3c.tar.gz
conf-abfbd65725ba45d0b7d17eca114574ed0be4de3c.zip
add some osx config
karabiner, bettertouchtool, amethyst, hammerspoon
Diffstat (limited to 'hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua')
-rw-r--r--hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua b/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua
new file mode 100644
index 0000000..bb83f67
--- /dev/null
+++ b/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua
@@ -0,0 +1,49 @@
+--- === ReloadConfiguration ===
+---
+--- Adds a hotkey to reload the hammerspoon configuration, and a pathwatcher to automatically reload on changes.
+---
+--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip)
+
+local obj = {}
+obj.__index = obj
+
+-- Metadata
+obj.name = "ReloadConfiguration"
+obj.version = "1.0"
+obj.author = "Jon Lorusso <jonlorusso@gmail.com>"
+obj.homepage = "https://github.com/Hammerspoon/Spoons"
+obj.license = "MIT - https://opensource.org/licenses/MIT"
+
+
+--- ReloadConfiguration.watch_paths
+--- Variable
+--- List of directories to watch for changes, defaults to hs.configdir
+obj.watch_paths = { hs.configdir }
+
+--- ReloadConfiguration:bindHotkeys(mapping)
+--- Method
+--- Binds hotkeys for ReloadConfiguration
+---
+--- Parameters:
+--- * mapping - A table containing hotkey modifier/key details for the following items:
+--- * reloadConfiguration - This will cause the configuration to be reloaded
+function obj:bindHotkeys(mapping)
+ local def = { reloadConfiguration = hs.fnutils.partial(hs.reload, self) }
+ hs.spoons.bindHotkeysToSpec(def, mapping)
+end
+
+--- ReloadConfiguration:start()
+--- Method
+--- Start ReloadConfiguration
+---
+--- Parameters:
+--- * None
+function obj:start()
+ self.watchers = {}
+ for _,dir in pairs(self.watch_paths) do
+ self.watchers[dir] = hs.pathwatcher.new(dir, hs.reload):start()
+ end
+ return self
+end
+
+return obj