XMonitorButton
XMonitorButton is a Monitor widget in LightGUI's XFrame widget set. A button that IS a live monitor: process, systemd unit, or TCP port.
XMonitorButton looks like a button and behaves like a monitor. Point it at a process name, a systemd unit, or a TCP port and it polls on a timer, glowing green while the target is up, red while it is down, and dim when it cannot tell. It is a button too, so clicking it can open details or restart the thing it watches.

Key methods
set_kind(kind)— what to watch: Process, Unit, or Portset_target(t)— the process name, unit name, or port numbercheck_process(name, pid)— is a process by this name running?check_unit(unit, out)— is this systemd unit active?check_port(port)— is anything listening on this TCP port?
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
Kind picks the check, target picks the thing: Port + "22" watches sshd, Process + "Xvfb" watches a process, Unit + "ssh.service" watches a unit.
XMonitorButton widget(display, screen, window, gc, &styles, 20, 20, 220, 60);
widget.set_kind(XMonitorButton::Port);
widget.set_target("22"); // sshd :22
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/XMonitorButton.cpp -lX11 -o XMonitorButtonRun it under Xvfb or a real X server; close the window to quit.
Example in the repo
The full working example is examples/XMonitorButton.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:
- lightgui (C)
- lightgui_rust (Rust)
- lightgui_python (Python)