mirror of
https://github.com/prdlk/noctalia-ostt.git
synced 2026-08-04 10:21:43 +00:00
feat(core): add example plugin with declarative and imperative API examples
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user