-
Notifications
You must be signed in to change notification settings - Fork 0
/
apps.lua
57 lines (51 loc) · 1.58 KB
/
apps.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- Application shortcuts
moduleString = moduleString .. "📌 - Apps\n"
-- Hotkeys that search for an app when combined with Hyper
local applicationHotkeys = {
f = 'Finder',
a = 'Activity Monitor',
g = 'Google Chrome',
i = 'iTerm',
s = 'Safari',
v = 'Visual Studio Code',
o = 'Microsoft Outlook',
e = 'Microsoft Excel',
p = 'Preview',
t = 'Microsoft Teams (work or school)',
x = 'KeePassXC',
u = 'Obsidian'
}
-- Register Hyper + Key to Launch or Focus the given app
for key, app in pairs(applicationHotkeys) do
hs.hotkey.bind(hyper, key, function()
hs.notify.new({title="Hammerspoon", informativeText="📌 " .. app, withdrawAfter=1}):send()
hs.application.launchOrFocus(app)
end)
hs.hotkey.bind(hyperNoShift, key, function()
hs.notify.new({title="Hammerspoon", informativeText="📌 " .. app, withdrawAfter=1}):send()
hs.application.launchOrFocus(app)
end)
end
-- hs.alert.show('Apps 📌: Ready to rock 🤘!')
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
function appHelp()
msg = ""
for key, app in pairsByKeys(applicationHotkeys) do
msg = msg .. key .. ":\t" .. app .. "\n"
end
hs.alert.show(msg, 5)
end
hs.hotkey.bind(hyper, "ß", appHelp)
hs.hotkey.bind(hyperNoShift, "ß", appHelp)