feat(core): add example plugin with declarative and imperative API examples

This commit is contained in:
Prad Nukala
2026-07-13 11:43:33 -04:00
parent cf75df6d5a
commit 79f0bce1a9
6 changed files with 333 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
--!nonstrict
-- Control-center [[shortcut]] entry: a quick-toggle tile.
--
-- shortcut.setLabel(text)
-- shortcut.setIcon(on [, off]) -- one glyph, or distinct on/off glyphs
-- shortcut.setActive(bool) -- toggle/highlight state
-- shortcut.setEnabled(bool)
-- onClick() / onRightClick()
--
-- State is shared via noctalia.state, so the plugin's other entries (widget,
-- service) could react to the toggle.
local on = noctalia.state.get("toggle") == true
local function render()
shortcut.setLabel(if on then "Example On" else "Example Off")
shortcut.setIcon("puzzle")
shortcut.setActive(on)
shortcut.setEnabled(true)
end
-- Initial state at load.
render()
function onClick()
on = not on
noctalia.state.set("toggle", on)
render()
end