-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.lua
88 lines (78 loc) · 2.63 KB
/
boot.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
76
77
78
79
80
81
82
83
84
85
86
87
88
require("utils/app_utils")
require("utils/log")
-- General things we want to do when macOS boots
local output, status = hs.execute("colima start --ssh-agent", true)
if not status then
hs.alert.show("Failed to start Colima: " .. output)
end
function startEssentialApps()
local essentialApps = {"Messages", "Cursor", "Slack", "Notion Calendar", "kitty", "Reminders", "Bear", "Vivid",
"Google Chrome", "Notion", "Trello", "Hammerspoon"}
logAction("Starting essential apps")
local startApp = function(appName)
if not hs.application.get(appName) then
hs.timer.doAfter(0.1, function()
logAction("Starting app: " .. appName)
hs.application.open(appName, 0, true)
logAction("App is done starting; hiding: " .. appName)
hideAppWhenAvailable(appName)
end)
else
log("App already running; not starting: " .. appName)
end
end
for i, appName in ipairs(essentialApps) do
hs.timer.doAfter((i - 1) * 0.25, function()
startApp(appName)
end)
end
end
function openDefaultRepos()
logAction("Opening default repos")
hs.execute("cursor ~/src/dotfiles")
hs.execute("cursor ~/src/hammerspoon")
end
function minimizeCursorWindows()
local cursor = hs.application.get("Cursor")
if cursor then
local windows = cursor:allWindows()
for _, window in ipairs(windows) do
window:minimize()
end
else
local minimizeExecuted = false
local iterations = 0
local timer
poll(function()
log("Minimizing cursor windows check")
if not minimizeExecuted and hs.application.get("Cursor") then
logAction("Minimizing cursor windows")
local cursorApp = hs.application.get("Cursor")
if cursorApp then
local cursorWindows = cursorApp:allWindows()
for _, window in ipairs(cursorWindows) do
window:minimize()
end
end
minimizeExecuted = true
return true -- Stop polling
end
return false -- Continue polling
end, 2, 30)
timer:start()
end
end
function defaultAppState()
hs.timer.doAfter(0, function()
startEssentialApps()
hs.timer.doAfter(1, function()
openDefaultRepos()
hs.timer.doAfter(1, function()
minimizeCursorWindows()
end)
end)
end)
hs.timer.doAfter(10, function()
hideAllApps()
end)
end