Initial commit of Hammerspoon config
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
--- HotkeyMapper.lua
|
||||
local obj = {}
|
||||
obj.registry = {}
|
||||
|
||||
obj.chooser = hs.chooser.new(function(choice)
|
||||
if not choice then return end
|
||||
end)
|
||||
|
||||
-- This is the function you'll use to log keys
|
||||
function obj:register(mod, key, description, source)
|
||||
table.insert(self.registry, {
|
||||
text = string.format("%s + %s: %s", hs.inspect(mod):gsub('"', ''), key:upper(), description),
|
||||
subText = "Source: " .. (source or "Unknown")
|
||||
})
|
||||
end
|
||||
|
||||
function obj:show()
|
||||
if #self.registry == 0 then
|
||||
hs.alert.show("No hotkeys registered in Mapper")
|
||||
return
|
||||
end
|
||||
table.sort(self.registry, function(a, b) return a.text < b.text end)
|
||||
obj.chooser:choices(self.registry)
|
||||
obj.chooser:show()
|
||||
end
|
||||
|
||||
function obj:init(mod, key)
|
||||
hs.hotkey.bind(mod, key, function() self:show() end)
|
||||
return self
|
||||
end
|
||||
|
||||
return obj
|
||||
Reference in New Issue
Block a user