-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
152 lines (131 loc) Β· 4.71 KB
/
Copy pathinit.lua
File metadata and controls
152 lines (131 loc) Β· 4.71 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
-- Hammerspoon Configuration
local slackStatus = require("slack_status")
local scratchpad = require("scratchpad")
local batteryIndicator = require("battery_indicator")
local hyperduck = require("hyperduck")
local windowManager = require("window_manager")
local gifFinder = require("gif_finder")
local screenBlur = require("screen_blur")
local stt = require("stt")
local clipboardHistory = require("clipboard_history")
local mouseGrid = require("mouse_grid")
local unifiedMenu = require("unified_menu")
-- Read Slack token from macOS Keychain
-- One-time setup: security add-generic-password -a "$USER" -s "slack-status-token" -w "xoxp-your-token-here"
local function getKeychainPassword(service, account)
local output, status = hs.execute(string.format(
'/usr/bin/security find-generic-password -s "%s" -a "%s" -w 2>/dev/null',
service, account
))
if status and output then
return output:gsub("%s+$", "") -- trim trailing whitespace
end
return nil
end
local slackToken = getKeychainPassword("slack-status-token", os.getenv("USER"))
if not slackToken then
hs.alert.show("Slack token not found in Keychain! Add it with:\nsecurity add-generic-password -a \"$USER\" -s \"slack-status-token\" -w \"your-token\"")
end
slackStatus.init({
token = slackToken,
-- WiFi network to status mapping
statusMap = {
["M-Net"] = {
text = "Working from home",
emoji = ":house:",
menuEmoji = "π ",
},
["POP2"] = {
text = "In the office",
emoji = ":office:",
menuEmoji = "π’",
},
["Serpens"] = {
text = "On the go",
emoji = ":iphone:",
menuEmoji = "π±",
}
},
-- Manual status options (shown in menu bar)
manualStatuses = {
{
name = "π Working from home",
text = "Working from home",
emoji = ":house:",
useEndOfDay = true
},
{
name = "π’ In the office",
text = "In the office",
emoji = ":office:",
useEndOfDay = true
},
{
name = "π± On the go",
text = "On the go",
emoji = ":iphone:",
useEndOfDay = true
},
{
name = "π€ Sick",
text = "Sick",
emoji = ":face_with_thermometer:",
useEndOfDay = true
},
{
name = "π¨ Sick child",
text = "Sick child",
emoji = ":child:",
useEndOfDay = true
}
},
-- Default status when not on a recognized network
defaultStatus = {
text = "",
emoji = "",
expiration = 0
},
-- Set to true to NOT clear your status when WiFi is not detected or on unknown networks
-- Set to false to clear status on unknown networks
preserveStatusOnUnknown = true,
-- Resilience configuration
wifiChangeDelay = 3, -- Seconds to wait after WiFi change before updating
maxRetries = 3, -- Maximum number of retry attempts for failed HTTP requests
retryBaseDelay = 2, -- Base delay in seconds for exponential backoff (2s, 4s, 8s)
-- Auto-refresh configuration (status expires after this interval, then gets refreshed)
refreshInterval = 5 * 60 - 10, -- 5 minutes - 10 seconds in seconds, so we refresh before the status expires
})
-- Initialize Scratchpad (Ctrl+Option+S to toggle)
scratchpad.init({})
-- Initialize Battery Indicator
batteryIndicator.init({})
-- Initialize Hyperduck URL opener
hyperduck.init({})
-- Initialize Window Manager (Rectangle-style shortcuts)
windowManager.init({})
-- Initialize GIF Finder (Ctrl+Option+G to toggle)
-- One-time setup: security add-generic-password -a "$USER" -s "klipy-api-key" -w "YOUR_API_KEY"
local klipyApiKey = getKeychainPassword("klipy-api-key", os.getenv("USER"))
gifFinder.init({
apiKey = klipyApiKey
})
-- Initialize Screen Blur (Ctrl+Alt+B to toggle)
screenBlur.init({})
-- Initialize STT (fn+Space toggle, fn+Shift hold-to-talk)
-- One-time setup: security add-generic-password -a "$USER" -s "mistral-api-key" -w "YOUR_API_KEY"
local mistralApiKey = getKeychainPassword("mistral-api-key", os.getenv("USER"))
stt.init({
llm_api_key = mistralApiKey,
})
-- Initialize Clipboard History (Ctrl+Alt+V to show)
clipboardHistory.init({})
-- Initialize Mouse Grid (tap left Cmd to toggle keyboard-driven mouse)
mouseGrid.init({})
-- Initialize Unified Menu (combines Slack Status, Hyperduck, Scratchpad, Screen Blur, Clipboard History)
unifiedMenu.init({
slackStatus = slackStatus,
hyperduck = hyperduck,
scratchpad = scratchpad,
screenBlur = screenBlur,
clipboardHistory = clipboardHistory,
})