Skip to main content

Module widget

Module widget 

Source
Expand description

Widgets: small panels shown beside the monitor, for whatever else someone wants on the same screen. A widget is either built in (a large clock) or fed by any command, which rigtop runs periodically and whose output it renders.

A command prints either plain text (one row per line) or JSON:

{"rows": [
  {"label": "5h", "value": "42% · resets 14:30", "gauge": 0.42, "level": "ok"},
  {"value": "rigtop", "heading": true},
  {"label": "busy", "value": "2 subagents", "level": "warn"}
]}

Every field is optional; text is accepted for value. level is one of normal, dim, ok, warn, bad; gauge is a fraction (0-1) drawn as a bar, colored from green to red along its length, or in the row’s level color with "gauge_style": "level" (for amounts left, where a full bar is good). Commands run on the machine that displays them, through the shell (sh -c, or cmd /C on Windows).

Structs§

CommandRunner
Runs a command every interval on its own thread. Dropping it stops the thread after the current run (without waiting for it).
Widget
A configured widget, ready to draw.
WidgetOutput
What a command reported.
WidgetRow
One line of a widget.
WidgetState
The latest result of a command widget.

Enums§

GaugeStyle
How a gauge is colored.
Level
How a row is colored.
WidgetSource
Where a widget’s content comes from.

Functions§

parse_output
JSON if the output looks like it, else one row per line.
run_command
Runs command through the shell, killing it after timeout. Returns its output, or why it failed (the last line of its stderr if any).
start_widgets
Starts the widgets of the configuration; notify is called whenever a command produced new content (to repaint).