-- require 'hyper'
-- -- -- local capslock= {"⌘", "⌥", "⌃", "⇧"}
-- local capslock= {"⌘", "⌥", "⌃"}
-- -- hs.hotkey.bind(capslock, "W", function()
-- -- hs.notify.new({title="Hammerspoon", informativeText="WWWWHello World"}):send()
-- -- end)
-- -- -- hs.hotkey.bind(capslock, "i", function()
-- -- -- hs.eventtap.keyStroke({}, 'UP')
-- -- -- end)
-- -- -- hs.hotkey.bind(capslock, "k", function()
-- -- -- hs.eventtap.keyStroke({}, 'DOWN')
-- -- -- end)
-- -- -- hs.hotkey.bind(capslock, "j", function()
-- -- -- hs.eventtap.keyStroke({}, 'LEFT')
-- -- -- end)
-- -- -- hs.hotkey.bind(capslock, "l", function()
-- -- -- hs.eventtap.keyStroke({}, 'RIGHT')
-- -- -- end)
-- -- hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
-- -- hs.notify.new({title="Hammerspoon", informativeText="Hello World"}):send()
-- -- end)
-- local capsHotkey = function(hotkey, keystroke)
-- hs.hotkey.bind(capslock, hotkey, function()
-- hs.eventtap.keyStroke({}, keystroke)
-- end)
-- end
-- capsHotkeys = {
-- {"i", "UP"},
-- {"j", "LEFT"},
-- {"k", "DOWN"},
-- {"l", "RIGHT"},
-- {"h", "HOME"},
-- {";", "END"},
-- {"u", "DELETE"},
-- {"o", "FORWARDDELETE"}
-- }
-- for i, key in ipairs(capsHotkeys) do
-- capsHotkey(key[1], key[2])
-- end
-- local capsModHotkey = function(hotkey, keystroke, mods)
-- hs.hotkey.bind(capslock, hotkey, function()
-- hs.eventtap.event.newKeyEvent(mods, keystroke, true)
-- end)
-- end
-- A variable for the Hyper Mode
-- local capslock = hs.hotkey.modal.new({"⌘", "⌥", "⌃"})
-- A global variable for the Hyper Mode
hyper = hs.hotkey.modal.new({}, 'F17')
-- Enter Hyper Mode when F18 (Hyper/Capslock) is pressed
function enterHyperMode()
hyper.triggered = false
hyper:enter()
end
-- Leave Hyper Mode when F18 (Hyper/Capslock) is pressed,
-- send ESCAPE if no other keys are pressed.
function exitHyperMode()
hyper:exit()
if not hyper.triggered then
hs.eventtap.keyStroke({}, 'ESCAPE')
end
end
-- Bind the Hyper key
f18 = hs.hotkey.bind({}, 'F18', enterHyperMode, exitHyperMode)
hyper:bind({}, "return", function()
local win = hs.window.frontmostWindow()
win:setFullscreen(not win:isFullscreen())
hyper.triggered = true
end)
local capslock= {"⌘", "⌥", "⌃"}
hs.hotkey.bind(capslock, "r", function()
hs.notify.new({title="Hammerspoon", informativeText="RELOAD"}):send()
hs.reload()
end)
hs.hotkey.bind(capslock, "c", function()
hs.eventtap.keyStroke({"cmd"}, "c")
end)
hs.hotkey.bind(capslock, "v", function()
hs.eventtap.keyStroke({"cmd"}, "v")
end)
local hyper = function(isdown)
return function(newMods, newKey)
return function()
-- k.triggered = true
local event = hs.eventtap.event.newKeyEvent(
newMods,
newKey,
isdown
)
event:post()
end
end
end
local hyperDown = hyper(true)
local hyperUp = hyper(false)
local hyperBind = function(mods, key, newMods, newKey)
-- k:bind(mods, key, msg, hyperDown(newMods, newKey), hyperUp(newMods, newKey), nil)
hs.hotkey.bind(mods, key, function()
hs.eventtap.event.newKeyEvent(newMods, newKey, true):post()
hs.eventtap.event.newKeyEvent(newMods, newKey, false):post()
end)
end
hotkeys = {
{capslock, "c", {"cmd"}, "c"},
{capslock, "v", {"cmd"}, "v"}
}
-- for i, key in ipairs(hotkeys) do
-- hyperBind(key[1], key[2], key[3], key[4])
-- end
-- for i, key in ipairs(capsModHotkeys) do
-- capsModHotkey(key[1], key[2], key[3])
-- end