Blog: Grid-based Tiling Window Management: init.lua

File init.lua, 2.1 KB (added by retracile, 20 months ago)

init.lua

Line 
1-- Set grids to use for different size screens
2hs.grid.setGrid('2x2', '1920x1080')
3hs.grid.setGrid('4x4', '3840x2160')
4
5-- Snap window
6hs.hotkey.bind({"cmd"}, "Return", function()
7  local win = hs.window.focusedWindow()
8  hs.grid.snap(win)
9end)
10
11-- Move window
12hs.hotkey.bind({"cmd"}, "Left", function()
13  local win = hs.window.focusedWindow()
14  hs.grid.snap(win)
15  hs.grid.pushWindowLeft(win)
16end)
17
18hs.hotkey.bind({"cmd"}, "Right", function()
19  local win = hs.window.focusedWindow()
20  hs.grid.snap(win)
21  hs.grid.pushWindowRight(win)
22end)
23
24hs.hotkey.bind({"cmd"}, "Up", function()
25  local win = hs.window.focusedWindow()
26  hs.grid.snap(win)
27  hs.grid.pushWindowUp(win)
28end)
29
30hs.hotkey.bind({"cmd"}, "Down", function()
31  local win = hs.window.focusedWindow()
32  hs.grid.snap(win)
33  hs.grid.pushWindowDown(win)
34end)
35
36-- Grow window
37hs.hotkey.bind({"cmd", "ctrl"}, "Left", function()
38  local win = hs.window.focusedWindow()
39  hs.grid.snap(win)
40  hs.grid.pushWindowLeft(win)
41  hs.grid.resizeWindowWider(win)
42end)
43
44hs.hotkey.bind({"cmd", "ctrl"}, "Right", function()
45  local win = hs.window.focusedWindow()
46  hs.grid.snap(win)
47  hs.grid.resizeWindowWider(win)
48end)
49
50hs.hotkey.bind({"cmd", "ctrl"}, "Up", function()
51  local win = hs.window.focusedWindow()
52  hs.grid.snap(win)
53  hs.grid.pushWindowUp(win)
54  hs.grid.resizeWindowTaller(win)
55end)
56
57hs.hotkey.bind({"cmd", "ctrl"}, "Down", function()
58  local win = hs.window.focusedWindow()
59  hs.grid.snap(win)
60  hs.grid.resizeWindowTaller(win)
61end)
62
63-- Shrink window
64hs.hotkey.bind({"cmd", "shift"}, "Left", function()
65  local win = hs.window.focusedWindow()
66  hs.grid.snap(win)
67  hs.grid.resizeWindowThinner(win)
68end)
69
70hs.hotkey.bind({"cmd", "shift"}, "Right", function()
71  local win = hs.window.focusedWindow()
72  hs.grid.snap(win)
73  hs.grid.resizeWindowThinner(win)
74  hs.grid.pushWindowRight(win)
75end)
76
77hs.hotkey.bind({"cmd", "shift"}, "Up", function()
78  local win = hs.window.focusedWindow()
79  hs.grid.snap(win)
80  hs.grid.resizeWindowShorter(win)
81end)
82
83hs.hotkey.bind({"cmd", "shift"}, "Down", function()
84  local win = hs.window.focusedWindow()
85  hs.grid.snap(win)
86  hs.grid.resizeWindowShorter(win)
87  hs.grid.pushWindowDown(win)
88end)
89
90