Skip to content

Commit 00f130c

Browse files
committed
feat(noctalia): stoa-keybinds bar plugin showing the keybind cheatsheet
Keyboard pill in the bar; click opens an attached panel with every bind grouped by section, right click opens the Super+/ yad cheatsheet. Data is read from stoa-keybinds-bar text, so the script stays the single source (including the niri substitutions). Optional compact apps line in the bar. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UckMrz997J3c6sMq3qn9Yt
1 parent 86ca1ef commit 00f130c

7 files changed

Lines changed: 353 additions & 8 deletions

File tree

‎config/noctalia/config.toml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ reserve_space = true
196196

197197
start = ["launcher", "workspaces", "taskbar"]
198198
center = ["clock"]
199-
# `stoa/drive:pill` and `stoa/health:pill` are the local plugins in
200-
# theme/noctalia-plugins/{stoa-drive,stoa-health} (plugin widgets are
201-
# addressed as <plugin-id>:<entry-id>).
202-
end = ["media", "tray", "notifications", "clipboard", "stoa/drive:pill", "stoa/health:pill", "sysmon", "network", "bluetooth", "volume", "brightness", "battery", "control-center", "session"]
199+
# `stoa/drive:pill`, `stoa/health:pill` and `stoa/keybinds:pill` are the local
200+
# plugins in theme/noctalia-plugins/{stoa-drive,stoa-health,stoa-keybinds}
201+
# (plugin widgets are addressed as <plugin-id>:<entry-id>).
202+
end = ["media", "tray", "notifications", "clipboard", "stoa/drive:pill", "stoa/health:pill", "stoa/keybinds:pill", "sysmon", "network", "bluetooth", "volume", "brightness", "battery", "control-center", "session"]
203203

204204
# ── Control centre shortcuts ──────────────────────────────────────────
205205

@@ -239,7 +239,8 @@ started = "~/.local/bin/stoa-doctor"
239239
# ── Plugins ───────────────────────────────────────────────────────────
240240
# Stoa's local plugins live in theme/noctalia-plugins/ and are symlinked
241241
# into ~/.local/share/noctalia/plugins by install.sh:
242-
# stoa/drive, stoa/health bar pills (see [bar.default] above)
242+
# stoa/drive, stoa/health, bar pills (see [bar.default] above)
243+
# stoa/keybinds
243244
# stoa/memento Memento Mori desktop widget (below)
244245
# stoa/predict text-prediction popup (Super+Shift+S)
245246
# alexander/screen-toolkit comes from the built-in community source: screen
@@ -251,7 +252,7 @@ started = "~/.local/bin/stoa-doctor"
251252
# plugins over IPC so an existing install picks up new ones too.
252253

253254
[plugins]
254-
enabled = ["stoa/drive", "stoa/health", "stoa/memento", "stoa/predict", "alexander/screen-toolkit"]
255+
enabled = ["stoa/drive", "stoa/health", "stoa/keybinds", "stoa/memento", "stoa/predict", "alexander/screen-toolkit"]
255256

256257
# ── Desktop widgets ───────────────────────────────────────────────────
257258
# One Memento Mori tile. No `output`: Noctalia puts it on the focused

‎dotfiles/.local/state/noctalia/settings.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,14 @@ manage_open_near_click = true
168168
[plugin_settings."stoa/health"]
169169
manage_open_near_click = true
170170

171+
[plugin_settings."stoa/keybinds"]
172+
manage_open_near_click = true
173+
171174
[plugin_settings."stoa/predict"]
172175
popup_placement = "attached"
173176

174177
[plugins]
175-
enabled = [ "stoa/drive", "stoa/health", "alexander/screen-toolkit", "stoa/memento", "stoa/predict" ]
178+
enabled = [ "stoa/drive", "stoa/health", "stoa/keybinds", "alexander/screen-toolkit", "stoa/memento", "stoa/predict" ]
176179

177180
[shell]
178181
external_ip_enabled = true

‎install.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ _link "${STOA_DIR}/theme/noctalia-plugins/stoa-drive" \
150150
"${NOCTALIA_PLUGINS}/stoa-drive"
151151
_link "${STOA_DIR}/theme/noctalia-plugins/stoa-health" \
152152
"${NOCTALIA_PLUGINS}/stoa-health"
153+
_link "${STOA_DIR}/theme/noctalia-plugins/stoa-keybinds" \
154+
"${NOCTALIA_PLUGINS}/stoa-keybinds"
153155
_link "${STOA_DIR}/theme/noctalia-plugins/stoa-memento" \
154156
"${NOCTALIA_PLUGINS}/stoa-memento"
155157
_link "${STOA_DIR}/theme/noctalia-plugins/stoa-predict" \
@@ -161,7 +163,7 @@ _link "${STOA_DIR}/theme/noctalia-plugins/stoa-predict" \
161163
# On a live shell, enable each through IPC instead; it appends to whatever
162164
# the user already has and is a no-op for one already enabled.
163165
if command -v noctalia &>/dev/null && noctalia msg plugins list &>/dev/null; then
164-
for plugin in stoa/drive stoa/health stoa/memento stoa/predict alexander/screen-toolkit; do
166+
for plugin in stoa/drive stoa/health stoa/keybinds stoa/memento stoa/predict alexander/screen-toolkit; do
165167
noctalia msg plugins enable "$plugin" &>/dev/null || \
166168
echo -e " ${S}[~] Could not enable ${plugin} (enable it in Settings → Plugins).${R}"
167169
done
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
-- ╔══════════════════════════════════════════════════════════════╗
2+
-- ║ STOA LINUX — Keybinds panel ║
3+
-- ║ The cheatsheet, laid out. ║
4+
-- ╚══════════════════════════════════════════════════════════════╝
5+
--
6+
-- Renders the output of `stoa-keybinds-bar text` — the same text Super+/
7+
-- shows in the yad dialog — as a scrollable list: one block per "▸"
8+
-- section, each bind as key (left) + description (right). Nothing is
9+
-- hard-coded here, so the panel follows the script, including its niri
10+
-- substitutions.
11+
--
12+
-- Written in the Lua 5.4-compatible subset of Luau (no type annotations,
13+
-- no if-expressions) so the CI lua step can actually parse it.
14+
15+
local KEYBINDS_BIN = "$HOME/.local/bin/stoa-keybinds-bar"
16+
local TOGGLE_BIN = "$HOME/.local/bin/stoa-keybinds-toggle"
17+
18+
-- ── UI tree node builders (same helpers as the stoa-health panel) ──
19+
local function node(kind, props, children)
20+
return { type = kind, props = props or {}, children = children or {} }
21+
end
22+
local function col(props, children) return node("column", props, children) end
23+
local function rowN(props, children) return node("row", props, children) end
24+
local function lbl(props) return node("label", props) end
25+
local function btn(props) return node("button", props) end
26+
local function sep(props) return node("separator", props) end
27+
local function scr(props, children) return node("scroll", props, children) end
28+
29+
-- ── State ──
30+
31+
local state = {
32+
loaded = false,
33+
failed = false,
34+
-- { { title = "Window", binds = { { key = "...", desc = "..." }, ... } }, ... }
35+
sections = {},
36+
binds = 0,
37+
}
38+
39+
-- ── Data ──
40+
41+
-- " Super+Return Terminal (kitty)" → key, desc. Key and
42+
-- description are separated by two or more spaces; the key never contains
43+
-- a space. The box-drawing banner lines and blank lines match neither
44+
-- pattern and are skipped.
45+
local function parseText(text)
46+
local sections, current, binds = {}, nil, 0
47+
for line in string.gmatch(text, "[^\n]+") do
48+
local title = string.match(line, "^▸%s*(.+)$")
49+
if title then
50+
current = { title = title, binds = {} }
51+
sections[#sections + 1] = current
52+
elseif current then
53+
local key, desc = string.match(line, "^%s+(%S+)%s%s+(%S.*)$")
54+
if key then
55+
current.binds[#current.binds + 1] = { key = key, desc = desc }
56+
binds = binds + 1
57+
end
58+
end
59+
end
60+
state.sections = sections
61+
state.binds = binds
62+
end
63+
64+
local function load()
65+
noctalia.runAsync(KEYBINDS_BIN .. " text", function(result)
66+
state.loaded = true
67+
if result.exitCode == 0 and result.stdout ~= "" then
68+
state.failed = false
69+
parseText(result.stdout)
70+
else
71+
state.failed = true
72+
end
73+
render()
74+
end)
75+
end
76+
77+
-- ── Rendering ──
78+
79+
local function bindRow(b)
80+
return rowN({ align = "center", gap = 10 }, {
81+
lbl({ text = b.key, fontSize = 12, fontWeight = "bold", color = "primary", width = 150 }),
82+
lbl({ text = b.desc, fontSize = 12, flexGrow = 1 }),
83+
})
84+
end
85+
86+
local function sectionBlock(section)
87+
local children = {
88+
lbl({ text = section.title, fontWeight = "bold", fontSize = 13 }),
89+
}
90+
for _, b in ipairs(section.binds) do
91+
children[#children + 1] = bindRow(b)
92+
end
93+
return col({ gap = 4 }, children)
94+
end
95+
96+
local function body()
97+
if not state.loaded then
98+
return col({ flexGrow = 1, align = "center", justify = "center" }, {
99+
lbl({ text = "…", color = "on_surface_variant" }),
100+
})
101+
end
102+
if state.failed or #state.sections == 0 then
103+
return col({ flexGrow = 1, align = "center", justify = "center", gap = 6 }, {
104+
lbl({ text = "Could not read the cheatsheet", color = "error" }),
105+
lbl({ text = "stoa-keybinds-bar text failed", color = "on_surface_variant", fontSize = 12 }),
106+
})
107+
end
108+
109+
local children = {}
110+
for i, section in ipairs(state.sections) do
111+
if i > 1 then children[#children + 1] = sep({ opacity = 0.3 }) end
112+
children[#children + 1] = sectionBlock(section)
113+
end
114+
return scr({ flexGrow = 1, gap = 10 }, children)
115+
end
116+
117+
function render()
118+
local subtitle = ""
119+
if state.loaded and not state.failed then
120+
subtitle = string.format("%d binds", state.binds)
121+
end
122+
123+
panel.render(col({ flexGrow = 1, gap = 10, padding = 12 }, {
124+
rowN({ align = "center" }, {
125+
lbl({ text = "Stoa Keybinds", fontWeight = "bold", flexGrow = 1 }),
126+
lbl({ text = subtitle, color = "on_surface_variant", fontSize = 12 }),
127+
}),
128+
sep({}),
129+
body(),
130+
sep({}),
131+
rowN({ gap = 6 }, {
132+
btn({ text = "Open as window", flexGrow = 1, controlSize = "sm", variant = "outline",
133+
onClick = function() noctalia.runAsync(TOGGLE_BIN) end }),
134+
}),
135+
}))
136+
end
137+
138+
-- ── Lifecycle ──
139+
140+
function onOpen(context)
141+
-- Re-read on every open: cheap, and it picks up a changed script or a
142+
-- compositor switch without restarting the shell.
143+
render()
144+
load()
145+
end
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# ╔══════════════════════════════════════════════════════════════╗
2+
# ║ STOA LINUX — Keybinds pill (Noctalia v5 plugin) ║
3+
# ║ The cheatsheet one click away, in the bar. ║
4+
# ╚══════════════════════════════════════════════════════════════╝
5+
#
6+
# Noctalia v5 ships no cheatsheet widget, so Super+/ used to be the only
7+
# way to see the binds (a yad text dialog, scripts/stoa-keybinds-toggle.sh).
8+
# This puts the same cheatsheet in the bar: a keyboard icon whose tooltip
9+
# lists the sections, and an attached panel with every bind grouped the
10+
# way the cheatsheet groups them.
11+
#
12+
# The data is NOT duplicated here. scripts/stoa-keybinds-bar.sh stays the
13+
# single source of truth (it already swaps the navigation lines on niri),
14+
# and this plugin only reads its `text` output and lays it out — so a new
15+
# bind added to that script shows up in the panel with no change here.
16+
#
17+
# Optionally the compact "most-used apps" line the old waybar module
18+
# carried can be shown next to the icon (setting `show_apps`); it follows
19+
# STOA_SHOW_KEYBINDS from stoa.conf, same as before.
20+
21+
id = "stoa/keybinds"
22+
name = "Stoa Keybinds"
23+
version = "1.0.0"
24+
author = "stoa"
25+
icon = "keyboard"
26+
description = "Keyboard shortcut cheatsheet — one icon, opens a panel with every bind"
27+
tags = ["bar", "keybinds", "help"]
28+
29+
# Same floor as the other Stoa plugins: panel.luau hands inline Lua
30+
# closures as onClick props (plugin API level 9, see stoa-drive).
31+
plugin_api = 9
32+
33+
[[widget]]
34+
id = "pill"
35+
entry = "widget.luau"
36+
37+
# Attached: opens anchored below the bar icon that toggled it, same as
38+
# stoa-drive and stoa-health.
39+
[[panel]]
40+
id = "cheatsheet"
41+
entry = "panel.luau"
42+
placement = "attached"
43+
width = 380
44+
height = 560
45+
46+
# Settings are an ARRAY of tables named `setting` (singular), each with an
47+
# explicit `key`; `label_key` is a translation key resolved against
48+
# translations/en.json.
49+
[[setting]]
50+
key = "icon"
51+
type = "glyph"
52+
default = "keyboard"
53+
label_key = "settings.icon.label"
54+
description_key = "settings.icon.description"
55+
56+
[[setting]]
57+
key = "show_apps"
58+
type = "bool"
59+
default = false
60+
label_key = "settings.show_apps.label"
61+
description_key = "settings.show_apps.description"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"settings": {
3+
"icon": {
4+
"label": "Icon",
5+
"description": "Glyph shown in the bar."
6+
},
7+
"show_apps": {
8+
"label": "Show app shortcuts in the bar",
9+
"description": "Display the compact line of the most-used app binds (Terminal, Launcher, Brave, Files…) next to the icon. Follows STOA_SHOW_KEYBINDS in stoa.conf."
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)