-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp_launch.lua
More file actions
36 lines (30 loc) · 843 Bytes
/
app_launch.lua
File metadata and controls
36 lines (30 loc) · 843 Bytes
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
local _M = {}
_M.name = "app_launch"
_M.description = "app启动或切换"
local apps = require "keybindings_config".apps
local log = hs.logger.new("appLaunch")
-- App显示或隐藏
local function toggleAppByBundleId(bundleID)
local frontApp = hs.application.frontmostApplication()
if frontApp:bundleID() == bundleID and frontApp:focusedWindow() then
log.d(string.format("hide app: %s", bundleID))
frontApp:hide()
else
log.d(string.format("launch app: %s", bundleID))
hs.application.launchOrFocusByBundleID(bundleID)
end
end
hs.fnutils.each(
apps,
function(item)
hs.hotkey.bind(
item.prefix,
item.key,
item.message,
function()
toggleAppByBundleId(item.bundleId)
end
)
end
)
return _M