Instantly share code, notes, and snippets.

@konamacona /init.lua Secret
Created Nov 13, 2018

Embed
What would you like to do?
Mitch Keenan's Hammerspoon Config
-- Mitch Keenan's Hammerspoon Config
-- Fancy hot reloading for this file, taken from http://www.hammerspoon.org/go/#fancyreload
function reloadConfig(files)
doReload = false
for _,file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
end
end
myWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
hs.alert.show("Config loaded")
-- Setup some shortcuts for tab switching in chrome
local left = hs.hotkey.bind({"ctrl", "option"}, "left", function()
hs.eventtap.keyStroke({"ctrl", "shift"}, "tab")
end):disable()
local right = hs.hotkey.bind({"ctrl", "option"}, "right", function()
hs.eventtap.keyStroke({"ctrl"}, "tab")
end):disable()
local chromeFilter = hs.window.filter.new(false):setAppFilter('Google Chrome')
chromeFilter:subscribe(hs.window.filter.windowFocused, function()
left:enable()
right:enable()
end)
chromeFilter:subscribe(hs.window.filter.windowUnfocused, function()
left:disable()
right:disable()
end)
-- Map Mouse buttons to browser forward and back
eventtapMiddleMouseDown = hs.eventtap.new({ hs.eventtap.event.types.otherMouseDown }, function(event)
-- back
if event:getButtonState(3) then
hs.eventtap.keyStroke({"cmd"}, "left")
end
-- forward
if event:getButtonState(4) then
hs.eventtap.keyStroke({"cmd"}, "right")
end
return false
end)
eventtapMiddleMouseDown:start()
-- Add hotkey for entering a string I type often
hs.hotkey.bind({}, "f18", function()
hs.eventtap.keyStrokes("XXXXXXXXX")
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment