Skip to content

Commit 3601e5e

Browse files
committed
Add support for mapping a Hyper binding to a custom function
1 parent b71f3ff commit 3601e5e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hammerspoon/hyper.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ if not status then
55
end
66

77
for i, mapping in ipairs(hyperModeAppMappings) do
8-
hs.hotkey.bind({'shift', 'ctrl', 'alt', 'cmd'}, mapping[1], function()
9-
hs.application.launchOrFocus(mapping[2])
8+
local key = mapping[1]
9+
local app = mapping[2]
10+
hs.hotkey.bind({'shift', 'ctrl', 'alt', 'cmd'}, key, function()
11+
if (type(app) == 'string') then
12+
hs.application.open(app)
13+
elseif (type(app) == 'function') then
14+
app()
15+
else
16+
hs.logger.new('hyper'):e('Invalid mapping for Hyper +', key)
17+
end
1018
end)
1119
end

0 commit comments

Comments
 (0)