-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
75 lines (65 loc) · 1.98 KB
/
init.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
68
69
70
71
72
73
74
75
local hyper = { "cmd", "alt", "ctrl", "shift" }
hs.hotkey.bind(hyper, "0", function()
hs.reload()
end)
hs.notify.new({title="Hammerspoon", informativeText="Config loaded"}):send()
function baseMove(x, y, w, h)
return function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.w * x + max.x
f.y = max.h * y
f.w = max.w * w
f.h = max.h * h
win:setFrame(f, 0)
end
end
hs.hotkey.bind(hyper, 'h', baseMove(0, 0, 0.5, 1))
hs.hotkey.bind(hyper, 'l', baseMove(0.5, 0, 0.5, 1))
hs.hotkey.bind(hyper, 'j', baseMove(0, 0.5, 1, 0.5))
hs.hotkey.bind(hyper, 'k', baseMove(0, 0, 1, 0.5))
hs.hotkey.bind(hyper, '1', baseMove(0, 0, 0.5, 0.5))
hs.hotkey.bind(hyper, '2', baseMove(0.5, 0, 0.5, 0.5))
hs.hotkey.bind(hyper, '3', baseMove(0, 0.5, 0.5, 0.5))
hs.hotkey.bind(hyper, '4', baseMove(0.5, 0.5, 0.5, 0.5))
hs.hotkey.bind(hyper, "g", function()
local win = hs.window.focusedWindow();
if not win then
return end win:moveToUnit(hs.layout.maximized)
end)
hs.window.animationDuration = 0
function moveWindowToDisplay(d)
return function()
local displays = hs.screen.allScreens()
local win = hs.window.focusedWindow()
win:moveToScreen(displays[d], false, true)
end
end
hs.hotkey.bind(hyper, "[", moveWindowToDisplay(1))
hs.hotkey.bind(hyper, "]", moveWindowToDisplay(2))
hs.hotkey.bind(hyper, '\\', function()
local screen = hs.mouse.getCurrentScreen()
local nextScreen = screen:next()
local rect = nextScreen:fullFrame()
local center = hs.geometry.rectMidPoint(rect)
hs.mouse.setAbsolutePosition(center)
hs.eventtap.leftClick(center)
end)
local applicationHotkeys = {
b = 'Brave Browser',
c = 'Google Chrome',
d = 'Discord',
f = 'Firefox',
i = 'iTerm',
p = 'Postman',
s = 'Spotify',
t = 'Telegram',
v = 'Visual Studio Code'
}
for key, app in pairs(applicationHotkeys) do
hs.hotkey.bind(hyper, key, function()
hs.application.launchOrFocus(app)
end)
end