Zren / plasma-applets

This monolithic repo has been broken up into individual repos for each widget.
84 stars 23 forks source link

Commandoutput with Indicator and Richtext Support #127

Open Shihira opened 6 years ago

Shihira commented 6 years ago
Shihira commented 6 years ago

PS: How I use this indicator mode

Imgur

Zren commented 6 years ago

Hmmm, if you hadn't already written the code, I'd have recommended the kargos widget (https://store.kde.org/p/1173112/ | https://github.com/lipido/kargos).

Anyways, lets break down the PR.

Changing the min interval to 50ms. Not sure why I thought 1sec was the minimum. I do remember PlasmaCore.DataSource having a hardcoded minimum though. We can confirm the shorter period works with:

Oh right, now I remember why.

While DataEngine.cpp does have a hardcoded minimum of 20 times a second (50ms).

DataEngine's also have the ability to set a minimum, which the executable dataengine sets as 1000ms.

ExecutableEngine::ExecutableEngine(QObject* parent, const QVariantList& args)
    : Plasma::DataEngine(parent, args)
{
    setMinimumPollingInterval(1000);
}

However, my assumption was wrong. That 1000ms is how often it checks to see if the process is still running. It can "update" sooner if the process finishes in just ~10ms.

We can confirm this by using date +%S.%N in the widget.

So nice catch, I should have tested that.

Zren commented 6 years ago
QT_DEVICE_PIXEL_RATIO=2 QML_DISABLE_DISK_CACHE=true plasmoidviewer -a package`
Shihira commented 6 years ago
Zren commented 6 years ago

I introduced linkRunner because I wanted to run some shell commands by clicking links (like launching ksysguard).

How are you formatting the "links"? <a href="ksysguard">KSysGuard</a> ?

Shihira commented 6 years ago

Yes. Is that weird?

Zren commented 6 years ago

It's a hackish way to do it, but that's fine I guess. I'll probably be adding the following after the merge:

onLinkActivated: {
    var urlStartRegex = /^\w+:\/\//
    if (urlStartRegex.match(link)) {
        Qt.openUrlExternally(link)
    } else { // Assume it's a command
        linkRunner.exec(link)
    }
}

So that you don't need to prefix urls with xdg-open like <a href="xdg-open http://google.com">