-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathkey-binding.lua
51 lines (47 loc) · 1.59 KB
/
key-binding.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
local wm = require('window-management')
local hk = require "hs.hotkey"
-- * Key Binding Utility
--- Bind hotkey for window management.
-- @function windowBind
-- @param {table} hyper - hyper key set
-- @param { ...{key=value} } keyFuncTable - multiple hotkey and function pairs
-- @key {string} hotkey
-- @value {function} callback function
local function windowBind(hyper, keyFuncTable)
for key,fn in pairs(keyFuncTable) do
hk.bind(hyper, key, fn)
end
end
-- * Move window to screen
windowBind({"ctrl", "alt"}, {
left = wm.throwLeft,
right = wm.throwRight
})
-- * Set Window Position on screen
windowBind({"ctrl", "alt", "cmd"}, {
m = wm.maximizeWindow, -- ⌃⌥⌘ + M
c = wm.centerOnScreen, -- ⌃⌥⌘ + C
left = wm.leftHalf, -- ⌃⌥⌘ + ←
right = wm.rightHalf, -- ⌃⌥⌘ + →
up = wm.topHalf, -- ⌃⌥⌘ + ↑
down = wm.bottomHalf -- ⌃⌥⌘ + ↓
})
-- * Set Window Position on screen
windowBind({"ctrl", "alt", "shift"}, {
left = wm.rightToLeft, -- ⌃⌥⇧ + ←
right = wm.rightToRight, -- ⌃⌥⇧ + →
up = wm.bottomUp, -- ⌃⌥⇧ + ↑
down = wm.bottomDown -- ⌃⌥⇧ + ↓
})
-- * Set Window Position on screen
windowBind({"alt", "cmd", "shift"}, {
left = wm.leftToLeft, -- ⌥⌘⇧ + ←
right = wm.leftToRight, -- ⌥⌘⇧ + →
up = wm.topUp, -- ⌥⌘⇧ + ↑
down = wm.topDown -- ⌥⌘⇧ + ↓
})
-- * Windows-like cycle
windowBind({"ctrl", "alt", "cmd"}, {
u = wm.cycleLeft, -- ⌃⌥⌘ + u
i = wm.cycleRight -- ⌃⌥⌘ + i
})