-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkeymaps.lua
67 lines (61 loc) · 1.7 KB
/
keymaps.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
58
59
60
61
62
63
64
65
66
67
local hyper = Hyper
local host = require("hs.host")
local on_personal = (host.names()[1] == "olis-macbook-pro.local" or host.names()[1] == "Oli")
------------------------------- APP LAUNCH/TOGGLE ------------------------------
--[[
The list of keys and apps which enable launching and toggling
Some apps have a different process name to their name on disk. To address
this, a table can be passed which contains the app name followed by the filename
]]
local apps = {
e = "Microsoft Excel",
f = "Finder",
g = "Google Chrome",
n = "Bear", -- Notes
o = "Notion", -- Life OS
r = "Reminders",
t = "WezTerm", -- Terminal
}
if on_personal then
apps.c = "Code" -- VS Code
apps.b = "Safari" -- Browser
apps.p = "1Password"
apps.w = "Microsoft Word"
else
apps.c = "Teams" -- Chat
apps.b = "Google Chrome" -- Browser
apps.m = "Microsoft Outlook" -- Mail
apps.p = "Microsoft PowerPoint"
apps.w = "Windows App"
apps.z = "Zoom"
end
local LaunchOrToggle = function(key, app_name, app_filename)
hs.hotkey.bind(hyper, key, function()
local app = hs.application.find(app_name)
-- Toggle - show
local awin = nil
if app then
awin = app:mainWindow()
end
-- Toggle - hide
if awin and app and app:isFrontmost() then
app:hide()
else
-- Launch
if app_filename then
return hs.application.launchOrFocus(app_filename)
end
app = hs.application.find(app_name)
hs.application.launchOrFocus(app_name)
app.setFrontmost(app)
app.activate(app)
end
end)
end
for key, app_name in pairs(apps) do
if type(app_name) == "table" then
LaunchOrToggle(key, app_name[1], app_name[2])
else
LaunchOrToggle(key, app_name)
end
end