Plugins
A plugin adds a status, a list or a surface. List it by name under plugins, with its settings beside it. Nothing loads unlisted, and one that fails to load is logged and left out. Every setting is in the reference.
Without QML
Most plugins need no QML: type = "command", under any name the shell does not take: a built-in status, list or state, menu, drafts. A source gives a value, and show says how each value looks.
plugins.doNotDisturb = {
type = "command";
watch = "dnd-status --follow"; # prints true or false on every change
activate = "dnd-toggle"; # a click on it in a bar
show = {
"true" = { glyph = ""; tone = "alert"; active = true; };
"false" = { glyph = ""; };
};
};
For a fixed set of choices, items lists them, for an entry whose list is the plugin’s name. The source’s value names the one in use, select runs with the chosen id, and run with an item’s id and the key of an action from its own menu.
plugins.displayLayout = {
type = "command";
read = "displayctl status"; # {"value": "extend", "enabled": ["laptop", "extend"]}
select = "displayctl layout";
items = [
{ id = "laptop"; label = "Laptop only"; icon = ""; }
{ id = "extend"; label = "Extend"; icon = ""; }
];
};
Sources
A plugin’s state comes from one source:
watch: a command that runs for as long as it lasts, each line the new state. It must flush each line (stdbuf -oL,--line-buffered), and is restarted when it exits.file: a file holding the state, read on every change. Replace it whole, by a rename: writes in place a moment apart can be missed.read: a command whose last line is the state, run as the menu opens and onceactivateends.qs -c quick-key ipc call <name> refreshruns it now.
The state line
A line is a plain value (true, 45, /walls/sunset.jpg) or a JSON object, an empty one clearing the state. An object’s fields, each optional:
value: whatshowanditemslook up; a plain line is its value.glyph,text,detail,active,tone: the look, over whatshowgives the value.phase: its work, as Rex’s Program Status Protocol names it.idle;working, its icon spinning where a bar entry shows one;blockedon you, in warning;done, lit, a result not seen yet;error, in alert. A word it does not know isidle. Awatchthat ends takesworkingandblockedwith it and leavesdoneanderrorto be seen.enabled: the ids ofitemsthat can be picked; unset, all.items: items that change, when the settings list none, each{ id, label, icon, glyphs, detail, swatch, active, enabled, done, hidden, busy, tone, verb, closes, actions }:donedims it, struck through; it can still be picked.hiddenleaves the rows; filtering (/) finds it.tone(warning) marks one that needs attention, withglyphsbefore its detail so colour is not all that says so.busyshows a spinner for its icon while it is being made.swatch, a colour that is data (#ff8c00, a task’s list), is a dot at the end of its row.verbnames what choosing it does in the picker’s legend (tick), andcloseshides the menu first.actions,[{ key, desc, icon, closes }], are its own menu (M-and its digit,M-RETwhile filtering), each runningrunwith the item’s id and the action’s key.
empty: whyitemsis empty, shown in its place (No devices paired).
A line that is not a JSON object is logged and skipped. The shell ignores fields it does not know, and a plugin may read its own (recording’s since).
Shipped
List one by name to use it: plugins.niriMinimap = { };.
command: the state its source gives, as above, under any name.dunst: do-not-disturb for those who keep dunst as their notification daemon. A bell, struck and lit while dunst is paused; a click pauses or resumes it. Needsdunstctlanddbus-monitoronPATH(with Nix, add dunst toextraPackages).mako: the same for mako, through a mode nameddo-not-disturbthat your mako config hides notifications in ([mode=do-not-disturb]withinvisible=1). Needsmakoctlanddbus-monitoronPATH(with Nix, add mako toextraPackages).recording: a pill on every screen while recording, and the elapsed time as a status. Its source gives{"active": true, "since": <epoch seconds>}while recording.dictation: a pill while dictating, a spinner while transcribing. Its source givesrecording,transcribingor anything else for idle, as its value or as thestageitsshowgives (show.streaming.stage = "recording").niriMinimap: a minimap of niri’s workspaces as you move between them.tasks: tasks to tick off, from a tasks file (see Tasks).ask: a panel for quick turns with an agent (see Ask).
Writing one in QML
A plugin that needs behaviour (a timer, a surface, a protocol) is a folder, found in $XDG_CONFIG_HOME/quick-key/plugins/ and then among the shipped ones. type names it, by default the plugin’s own name, or gives a path to its file.
<Name>.qml, rooted atPlugin: its state and actions. It never draws.Settings.qml, rooted atPluginSettings: every setting it takes, with its default and a one-line comment, which is its entry in the reference. It is read as the configuration builds, so it must stay declarative; the shell creates it once to check the config and once to run the plugin.- One file per view it draws, listed in
views(["Minimap.qml"]). Each is given the plugin aspluginand only reads it. - A type of its own it uses by name (Ask’s
Acp), listed in aqmldirbeside it (Acp 1.0 Acp.qml), since the shipped folders resolve no type without one.
import qs brings Plugin, PluginSettings and Config, qs.ui the kit and qs.services the services. The smallest to start from is plugins/dunst/, all of it settings.
What it gets:
name,settings(its part of the config), andstate(the state line, withshowanditemsapplied).exec(setting, ...args)runs a command setting, its arguments as$1,$2after its text, which the check fails when it ends in;,&or|.call(setting, args, then)runs one and always answersthen(code, output)once done (127 when unset), so a second call never drops one still running; one that exits non-zero is logged with its last line on stderr.commandLine(setting, ...args)builds one for aProcess.- The theme (
Config.theme) and the menu’s settings (Config.menu), the kit, and the services:Audio,Network,Bluez,Power,Brightness,Music,Tray,Compositor,Nirifor niri’s own events, and:Picker:pick(list)shows a list by name, filtered, on a menu level of its own over the plugin’s panel, which Escape shows again.Panels, the stack of surfaces:topis the one showing,open(owner)shows a plugin’s panel on top,back()closes it to show what it covered, andclose()hides them all.Kept, what is kept by key over a reload or a restart:set(key, value)writes one, and aKeptValue { key }binds to itsvalue.
What it gives:
glyph,text,detail,glyphs(before the detail, in its tone),activeandtone, shown wherever its name is astatus, andfieldsby name for an entry’sformat.fieldTones: a tone per field, kept when aformatshows it ({ updated: "warning" }on an old sync).error: why its source or its last action failed, by default its state’s ownerror. A level listing it shows it beside its keys, inalert.activate()for a click on it in a bar, andrefresh(), called as the menu opens.press(path)for a key path on a surface of its own (<name> press "2 x"), run as typing it would; false if it takes none.items,select(id)andrun(id, key)(an action from an item’s own menu) for an entry whoselistis its name. An item may bring ameter(0 to 1).actions: actions by name, as the built-in ones ({ icon, detail, available, run }), which an entry of a level listing it names in itsaction(the tasks’sort).words: what only it says (its empty list, its failures). The words the surfaces share areWords’s, which a plugin never adds to.submit(text, after, context)for an input’s text when it sets nocmd, runningafteronce done;contextis the input’s, for an agent to be told beside the text. It answers false when it does not take the text, which the input then keeps.busywhile it takes no text shows a spinner in the input; a plugin sets itsphaseto working or blocked rather thanbusy.watchedwhile the menu shows an input giving it text, set as a visit starts, andvisitEnded(throughendVisit()) as it ends: the menu leaves the level or closes. The keys moving between islands end none.displayedwhile watched and its input is the one on screen: false while the keys are on a pinned level, whose input shows instead, or a panel covers the menu. Ask notifies an answer that comes then, and marks it read once its input shows it.turn, the conversation’s turn as the menu draws it while watched, null before the first:{ question, text, phase, kind, activity, table, steps }.phaseis a state line’s:working(withactivity),done,blocked(kindpermission),error(the input getting the text back), oridleonce stopped.stepsare what you answered on the way (an approval).recall()to show its past conversations filtered in the menu, forC-rin an input giving it text, whilerecalls: the picker opens over what asked for it.expand()to show the conversation in its own panel over the menu, when the answer over the input cannot fit it; stepping back shows the menu again where it was, the visit going on. It answers false without a panel.empty: why its list is empty, shown in its place; by default its state’s ownempty.shortcut, its compositor key.
Every plugin answers <name> activate, <name> refresh and <name> action <action> over IPC, the last running one of its actions as an entry naming it would.