-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfocus_mode.lua
More file actions
64 lines (49 loc) · 1.75 KB
/
Copy pathfocus_mode.lua
File metadata and controls
64 lines (49 loc) · 1.75 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
-- focus_mode.lua
-- A plugin that combines visibility toggles, text overrides, and custom
-- components to create a "focus mode" — hiding the sidebar, relabeling the
-- header, and injecting a motivational quote at the bottom of the screen.
-- Toggled on/off with a single keybinding.
local matcha = require("matcha")
local quotes = {
"Inbox zero is a journey, not a destination.",
"One email at a time.",
"Reply boldly, archive freely.",
"The best email is the one you just sent.",
"Focus on what matters, not what pings.",
}
local active = false
local current_quote = ""
local function enable()
active = true
current_quote = quotes[math.random(#quotes)]
-- Hide the sidebar for distraction-free reading
matcha.ui.set_visible("sidebar", false)
-- Override the inbox title to show "Focus Mode"
matcha.ui.set_text("folder_inbox.folders_title", "")
-- Inject a quote at the bottom of the screen
matcha.ui.add_component("quote", " " .. current_quote .. " ", "bottom_left")
matcha.notify("Focus mode enabled", {duration = 2, kind = "info", closable = true})
end
local function disable()
active = false
-- Restore all UI elements
matcha.ui.set_visible("sidebar", true)
-- Remove the quote component by setting empty content
matcha.ui.add_component("quote", "", "bottom_left")
matcha.notify("Focus mode disabled", {duration = 2, kind = "info", closable = true})
end
matcha.on("startup", function()
-- Don't auto-enable; let the user decide with the keybinding.
end)
matcha.bind_key("ctrl+f", "inbox", "toggle focus mode", function()
if active then
disable()
else
enable()
end
end)
matcha.on("shutdown", function()
if active then
disable()
end
end)