-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
119 lines (103 loc) · 3.51 KB
/
init.lua
File metadata and controls
119 lines (103 loc) · 3.51 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
local winMR = require 'windowMoveResize'
local mouseHotkey = require 'mouseHotkey'
local windowUtil = require 'windowUtil'
local super = { 'ctrl', 'cmd' }
local superAlt = { 'ctrl', 'cmd', 'alt' }
local superShift = { 'ctrl', 'cmd', 'shift' }
-- super + alt + r 重载配置
hs.hotkey.bind(superAlt, 'r', function() hs.reload() end)
-- 需要“仅关闭窗口”绝不退出的应用名单
local ONLY_CLOSE_APPS = {
['微信'] = true,
['QQ'] = true,
['访达'] = true,
}
--------------------------------------------------------------------------------
-- 窗口操作
--------------------------------------------------------------------------------
mouseHotkey.hotkeyBindWithMouseDown(super, 'left', winMR.MoveWindowUseMouse)
mouseHotkey.hotkeyBindWithMouseDown(super, 'right', winMR.ReSizeWindowUseMouse)
hs.hotkey.bind(super, 't', function()
local win = hs.window.focusedWindow()
windowUtil.toggleMaximize(win)
end)
hs.hotkey.bind(super, 'q', function() windowUtil.smartCloseWindow(ONLY_CLOSE_APPS) end)
hs.hotkey.bind(super, 'tab', windowUtil.focusNextWindowInCurrentSpace)
--------------------------------------------------------------------------------
-- 应用启动
--------------------------------------------------------------------------------
-- hs.hotkey.bind(super, 'c', function()
-- local task = hs.task.new('/usr/bin/open', nil, {
-- '-n',
-- '-a',
-- '/Applications/Google Chrome.app',
-- '--args',
-- '--new-window',
-- })
-- task:start()
-- end)
hs.hotkey.bind(super, 'c', function()
local task = hs.task.new('/usr/bin/open', nil, {
'-n',
'-a',
'/Applications/Nix Apps/Firefox.app',
'--args',
'-new-window',
})
task:start()
end)
hs.hotkey.bind(super, 'space', function()
local task = hs.task.new('/usr/bin/open', nil, {
'-n',
'-a',
'/Applications/Nix Apps/kitty.app',
'--args',
'-d',
os.getenv 'HOME',
'-o',
'remember_window_size=no',
'-o',
'initial_window_width=1050',
'-o',
'initial_window_height=650',
})
task:start()
end)
hs.hotkey.bind(super, 'return', function()
local task = hs.task.new('/usr/bin/open', nil, {
'-n',
'-a',
'/Applications/Nix Apps/kitty.app',
'--args',
'-d',
os.getenv 'HOME',
'--start-as=maximized',
})
task:start()
end)
hs.hotkey.bind(super, 'p', function() hs.application.launchOrFocus 'Raycast' end)
-- 使用 raycast 绑定的快捷键(不受 hs 管理)
-- super + e 打开访达
--------------------------------------------------------------------------------
-- 媒体控制
--------------------------------------------------------------------------------
hs.hotkey.bind(superShift, 'up', function()
local dev = hs.audiodevice.defaultOutputDevice()
dev:setVolume(dev:volume() + 5)
hs.alert.closeAll()
hs.alert.show('音量: ' .. math.floor(dev:volume() + 0.5) .. '%', { atScreenEdge = 2 })
end)
hs.hotkey.bind(superShift, 'down', function()
local dev = hs.audiodevice.defaultOutputDevice()
dev:setVolume(dev:volume() - 5)
hs.alert.closeAll()
hs.alert.show('音量: ' .. math.floor(dev:volume() + 0.5) .. '%', { atScreenEdge = 2 })
end)
--------------------------------------------------------------------------------
-- 其他
--------------------------------------------------------------------------------
hs.hotkey.bind(superAlt, 'l', hs.caffeinate.lockScreen)
--------------------------------------------------------------------------------
-- End
--------------------------------------------------------------------------------
hs.alert.show '配置已重载'