-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindings.lua
51 lines (40 loc) · 1.4 KB
/
bindings.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
require 'window_functions';
-- Setup timer to stash every minute
hs.timer.doEvery(60, stashWindowPositions);
local lastScreenCount = 0;
-- Setup screen watcher to restore window positions
screenWatcher = hs.screen.watcher.new(function()
-- Don't restore if screen count hasn't changed. This happens when laptop lid is closed
local screenCount = tablelength(hs.screen.allScreens());
if (screenCount == lastScreenCount) then
return;
end;
lastScreenCount = screenCount;
hs.timer.doAfter(5, function()
if restoreWindowPositions(false) == false then
arrangeApps(apps, true);
stashWindowPositions();
end;
end);
end);
screenWatcher:start()
-- Setup hotkey bindings
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "l", listApps);
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "a", function()
arrangeApps(apps, true);
stashWindowPositions();
end);
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "r", function()
restoreWindowPositions(true);
end);
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "s", function()
stashWindowPositions(true);
end);
hs.hotkey.bind({"cmd", "alt", "ctrl"}, ".", function()
scaleWindow(hs.window.frontmostWindow(), 50);
end);
hs.hotkey.bind({"cmd", "alt", "ctrl"}, ",", function()
scaleWindow(hs.window.frontmostWindow(), -50);
end);
-- load config on save
hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()