plasma-show-stdout
A KDE Plasma 6 widget that displays stdout of shell scripts to the panel
Loading...
Searching...
No Matches
PSSspace::ScriptOutput Class Reference

QML bridge exposing combined script output. More...

#include <plasma-show-stdout.hpp>

Inheritance diagram for PSSspace::ScriptOutput:
[legend]
Collaboration diagram for PSSspace::ScriptOutput:
[legend]

Signals

void textChanged ()
 Change-notification signal for the text property.
void delimiterChanged ()
 Change-notification signal for the delimiter property.

Public Member Functions

 ScriptOutput (QObject *parent=nullptr)
 QML constructor.
 ScriptOutput (std::vector< ModuleSpec > specs, QObject *parent=nullptr)
 Constructor from a list of module specifications.
 ~ScriptOutput () override
 Destructor.
QString text () const
 Text output.
QString delimiter () const
 Delimiter inserted between module outputs.
void setDelimiter (const QString &delimiter)
 Set the delimiter inserted between module outputs.
int maxSignalOffset () const
 Largest valid realtime-signal offset.
qint64 hostPid () const
 PID of the process hosting this plugin.
QString hostName () const
 Command name of the process hosting this plugin.
Q_INVOKABLE void setModules (const QVariantList &specs)
 (Re)configure the running modules from QML

Properties

QString text
 Combined, delimiter-joined output of all modules (read-only).
QString delimiter
 Separator inserted between adjacent module outputs.
int maxSignalOffset
 Largest valid realtime-signal offset, SIGRTMAX - SIGRTMIN (constant).
qint64 hostPid
 PID of the host process the plugin is loaded into (constant).
QString hostName
 Command name of the host process, as pkill matches it (constant).

Detailed Description

QML bridge exposing combined script output.

QObject registered with QML as the ScriptOutput type. Owns the worker and bridge threads for a list of ModuleSpecs and joins their outputs into the text property for display. Constructed empty by QML, then (re)configured at runtime via setModules. The exposed properties and methods are documented individually below.

Constructor & Destructor Documentation

◆ ScriptOutput() [1/2]

PSSspace::ScriptOutput::ScriptOutput ( QObject * parent = nullptr)
explicit

QML constructor.

The entry point used by QML, which can only invoke a (QObject *parent) constructor. Starts with an empty module list (defaultSpecs()); the QML config wiring then populates it at runtime via setModules. Delegates to the spec-taking constructor.

Parameters
[in]parentPointer to the parent object

◆ ScriptOutput() [2/2]

PSSspace::ScriptOutput::ScriptOutput ( std::vector< ModuleSpec > specs,
QObject * parent = nullptr )
explicit

Constructor from a list of module specifications.

Spawns one worker (and bridge) thread per spec, in the given order; their outputs are joined into the text property. This is the real constructor; the QML constructor delegates to it.

Parameters
[in]specsmodules to run, in display order
[in]parentPointer to the parent object

Member Function Documentation

◆ delimiter()

QString PSSspace::ScriptOutput::delimiter ( ) const
inline

Delimiter inserted between module outputs.

Returns
the string joining adjacent module fragments in text

◆ hostName()

QString PSSspace::ScriptOutput::hostName ( ) const

Command name of the process hosting this plugin.

Read from /proc/self/comm, i.e. exactly what pkill <name> matches against (the kernel comm, truncated to 15 characters). Exposed so the config UI can show a working pkill --signal RTMIN+N <name> trigger command: the kill shell builtin (e.g. zsh's) does not accept an RTMIN+N signal spec, whereas pkill (a real binary) does. The name is the actual host — plasmashell, plasmoidviewer, plasmawindowed — so the command targets the right process regardless of how the widget is run.

Returns
the host process command name, or an empty string if unreadable

◆ hostPid()

qint64 PSSspace::ScriptOutput::hostPid ( ) const

PID of the process hosting this plugin.

The PID of the process the plugin is loaded into (plasmashell in normal use, or plasmawindowed/plasmoidviewer when testing). A signal module is triggered by sending SIGRTMIN+N to this process, so the config UI shows this PID to make the trigger command unambiguous regardless of which host is running the widget.

Returns
the host process PID (QCoreApplication::applicationPid())

◆ maxSignalOffset()

int PSSspace::ScriptOutput::maxSignalOffset ( ) const

Largest valid realtime-signal offset.

The inclusive upper bound for a signal module's RTMIN offset, i.e. SIGRTMAX - SIGRTMIN. Exposed so the config UI can size its spinbox without hard-coding glibc-specific signal numbers (SIGRTMIN/ SIGRTMAX are runtime calls, not constants).

Returns
the maximum offset N usable as SIGRTMIN + N

◆ setDelimiter()

void PSSspace::ScriptOutput::setDelimiter ( const QString & delimiter)

Set the delimiter inserted between module outputs.

A single delimiter is used between every adjacent pair of fragments (the underlying join is one string, not per-module). Rebuilds and re-emits text immediately from the existing fragments, so the display updates without restarting any worker. Runs on the GUI thread (as does the bridge's text rebuild), so no locking is needed.

Parameters
[in]delimiterthe new separator (empty joins with nothing)

◆ setModules()

Q_INVOKABLE void PSSspace::ScriptOutput::setModules ( const QVariantList & specs)

(Re)configure the running modules from QML

Tears down any currently running modules and starts the ones described by specs. Each entry is a map with keys kind (0 = Timed, 1 = Signal), script (path string), interval (seconds, Timed only), signalOffset (RTMIN offset, Signal only) and optional outputLimit. Entries with an empty script are skipped. This is the runtime entry point the QML config wiring calls; the signal number passed to a SignalModule is computed here as SIGRTMIN + signalOffset.

Parameters
[in]specsmodule descriptions, in display order

◆ text()

QString PSSspace::ScriptOutput::text ( ) const
inline

Text output.

Returns
A QString object for display

The documentation for this class was generated from the following file: