Skip to content

Instantly share code, notes, and snippets.

@tylergets
Forked from dalemanthei/init.lua
Created October 7, 2016 00:01
Show Gist options
  • Save tylergets/4b6bd4b916f8b52451f23be8828f71cf to your computer and use it in GitHub Desktop.
Save tylergets/4b6bd4b916f8b52451f23be8828f71cf to your computer and use it in GitHub Desktop.
Hamerspoon config examples for hyper key
-- hattip https://github.com/lodestone/hyper-hacks
-- hattip https://gist.github.com/ttscoff/cce98a711b5476166792d5e6f1ac5907
-- hattip https://gist.github.com/prenagha/1c28f71cb4d52b3133a4bff1b3849c3e
local hyper = {'cmd','alt','shift','ctrl'}
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- The following keys are configured as hot keys in their respective apps (or in Keyboard Maestro)
-- d → Dash (configure in Dash preferences)
-- m → Moom (configure in Moom preferences)
-- n → Notifications configure in System preferences → Keyboard → Shortcuts → Mission Control)
-- f → Fantastical (configure in Fantastical preferences)
-- t → Typinator (configure in Typinator preferences)
-- SPACE → Spotlight (configure in System Preferences → Keyboard → Shortcuts → Spotlight, moved so that ⌘␣ could be used for Quicksilver)
hyperBindings = {'d','m','n','f','t','SPACE'}
for i,key in ipairs(hyperBindings) do
k:bind({}, key, nil, function() hs.eventtap.keyStroke(hyper, key)
k.triggered = true
end)
end
-- Simple volume controls
-- k:bind({}, 'p', nil, function() hs.audiodevice.defaultOutputDevice():setMuted(true) end
k:bind({}, ']', nil, function() hs.audiodevice.defaultOutputDevice():setVolume(hs.audiodevice.current().volume + 5) end)
k:bind({}, '[', nil, function() hs.audiodevice.defaultOutputDevice():setVolume(hs.audiodevice.current().volume - 5) end)
-- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
pressedF18 = function()
k.triggered = false
k:enter()
end
-- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed,
-- send ESCAPE if no other keys are pressed.
releasedF18 = function()
k:exit()
if not k.triggered then
hs.eventtap.keyStroke({}, 'ESCAPE')
end
end
-- Bind the Hyper key
f18 = hs.hotkey.bind({}, 'F18', pressedF18, releasedF18)
-- local alert_sound = hs.sound.getByFile("alert.wav")
local alert_sound = hs.sound.getByName("Tink")
alert_sound:play()
hs.alert.show("Hammerspoon, at your service.", 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment