XMonitorGrid

XMonitorGrid

XMonitorGrid is a Monitor widget in LightGUI's XFrame widget set. A panel of XMonitorButtons in a labelled grid, on one shared poll timer.

XMonitorGrid is the status board: a labelled grid of XMonitorButtons that share one poll timer instead of each button polling on its own. Add one monitor per thing you care about — services, processes, ports — and the whole board lights up green or red together.

XMonitorGrid running under Xvfb
XMonitorGrid running — screenshot taken from the example below under Xvfb.

Key methods

  • add_monitor(label, kind, target) — add one button to the grid
  • layout() — re-lay out the grid after adding monitors

Every widget also gets the shared properties visible, enabled, bounds (x, y, width, height) and style_name, plus the background / foreground colours from the active style.

Example

One shared timer polls every button in the grid — add monitors, then draw.

XMonitorGrid widget(display, screen, window, gc, &styles, 20, 20, 720, 480);
widget.add_monitor("sshd :22",     XMonitorButton::Port,    "22");
widget.add_monitor("Xvfb",         XMonitorButton::Process, "Xvfb");
widget.add_monitor("ssh service",  XMonitorButton::Unit,    "ssh.service");
widget.add_monitor("docker :2375", XMonitorButton::Port,    "2375");
widget.draw();

The snippet above is the widget part only. As with every XFrame example, the full program opens a display, creates a window and a style manager, then runs the standard event loop — see the complete example in the repo.

Build it from the repo root:

g++ -std=c++17 -Iwidgets/components -Iwidgets examples/XMonitorGrid.cpp -lX11 -o XMonitorGrid

Run it under Xvfb or a real X server; close the window to quit.

Example in the repo

The full working example is examples/XMonitorGrid.cpp in the lightgui repo (C is canonical). The same widget is ported to the Rust and Python repos under the same name — see the links below.

Get the code

These widgets ship in all three LightGUI repos:

See also

Linux Rocks Every Day
Source code: LightGUI (C) · LightGUI (Rust) · LightGUI (Python)