Compare commits

...

2 Commits

Author SHA1 Message Date
ca530e6a7f Release 4.1.0 2026-02-06 13:56:56 +02:00
fff3a70ac6 GPU memory support (#176)
* gpu memory demo

* fetch snapshot data on subsrciption

* move device added to the end
2026-02-05 11:35:11 +02:00
22 changed files with 362 additions and 15 deletions

View File

@@ -1,3 +1,7 @@
Ver.4.1.0:
+ new keys gpumem*, gpuused*, gputot*, gpufree* for GPU memory (#175)
* rewrite dataengine processor to work in signleton mode (#174)
Ver.4.0.3:
- drop qml definition to avoid compile errors

View File

@@ -2,7 +2,7 @@
pkgname=plasma6-applet-awesome-widgets
_pkgname=awesome-widgets
pkgver=4.0.5
pkgver=4.1.0
pkgrel=1
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
arch=('x86_64')

View File

@@ -18,8 +18,8 @@ set(PROJECT_AUTHOR "Evgeniy Alekseev")
set(PROJECT_CONTACT "esalexeev@gmail.com")
set(PROJECT_LICENSE "GPL3")
set(PROJECT_VERSION_MAJOR "4")
set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "5")
set(PROJECT_VERSION_MINOR "1")
set(PROJECT_VERSION_PATCH "0")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
# append git version if any
set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "")

View File

@@ -19,7 +19,7 @@
"Id": "org.kde.plasma.awesomewidget",
"License": "GPLv3",
"Name": "Awesome Widget",
"Version": "4.0.5",
"Version": "4.1.0",
"Website": "https://arcanis.me/projects/awesome-widgets/"
},
"X-Plasma-API-Minimum-Version": "6.0"

View File

@@ -63,7 +63,7 @@ void AWDataEngineAggregator::connectSources()
auto keys = m_sensors.keys();
auto newKeys = QSet(keys.cbegin(), keys.cend()) - m_subscribed;
m_interface->subscribe(newKeys.values()).waitForFinished();
subscribeSources(newKeys.values());
m_subscribed.unite(newKeys);
}
@@ -106,6 +106,19 @@ void AWDataEngineAggregator::registerClient(QObject *_client)
}
void AWDataEngineAggregator::subscribeSources(const QStringList &_sources)
{
qCDebug(LOG_AW) << "Subscribe on sources" << _sources;
// subscribe
m_interface->subscribe(_sources).waitForFinished();
// get data snapshot
auto data = m_interface->sensorData(_sources);
data.waitForFinished();
updateData(data);
}
void AWDataEngineAggregator::unregisterClient(QObject *_client)
{
qCDebug(LOG_AW) << "Unregister client" << _client;
@@ -162,7 +175,7 @@ void AWDataEngineAggregator::sensorAdded(const QString &_sensor)
m_sensors[_sensor] = info;
dropSource(_sensor); // force reconnect
if (!m_subscribed.contains(_sensor)) {
m_interface->subscribe({_sensor}).waitForFinished();
subscribeSources({_sensor});
m_subscribed.insert(_sensor);
}

View File

@@ -54,6 +54,7 @@ public:
[[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor);
void loadSources();
void registerClient(QObject *_client);
void subscribeSources(const QStringList &_sources);
void unregisterClient(QObject *_client);
signals:

View File

@@ -43,6 +43,10 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus
m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance();
m_formatter["uptotkb"] = AWPluginFormatterMemory::instance();
m_formatter["upunits"] = AWPluginFormatterNetUnits::instance();
// gpu memory
m_formatter["gpumem"] = AWPluginFormatterFloat::instance();
m_formatter["gpufreemb"] = AWPluginFormatterMemoryMB::instance();
m_formatter["gpufreegb"] = AWPluginFormatterMemoryGB::instance();
}
@@ -109,4 +113,12 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings)
{
m_settings = _settings;
// update formatters
// gpu memory per device
for (auto i = 0; i < m_settings.gpu.count(); ++i) {
m_formatter[QString("gpumem%1").arg(i)] = AWPluginFormatterFloat::instance();
m_formatter[QString("gpufreemb%1").arg(i)] = AWPluginFormatterMemoryMB::instance();
m_formatter[QString("gpufreegb%1").arg(i)] = AWPluginFormatterMemoryGB::instance();
}
}

View File

@@ -70,12 +70,12 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
qCDebug(LOG_AW) << "Looking for required keys in" << _keys << _bars << "using tooltip settings" << _tooltip;
// initial copy
QSet<QString> used(_keys.cbegin(), _keys.cend());
QSet used(_keys.cbegin(), _keys.cend());
used.unite(QSet(_bars.cbegin(), _bars.cend()));
used.unite(QSet(_userKeys.cbegin(), _userKeys.cend()));
// insert keys from tooltip
for (auto [key, value] : _tooltip.asKeyValueRange()) {
if ((key.endsWith("Tooltip")) && value.toBool()) {
if (key.endsWith("Tooltip") && value.toBool()) {
auto local = key;
local.remove("Tooltip");
used << local;
@@ -84,7 +84,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
// insert keys which depend on others, refer to AWKeys::calculateValues()
// network keys
QStringList netKeys(
static QStringList netKeys(
{"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"});
for (auto &key : netKeys) {
if (!used.contains(key))
@@ -96,11 +96,13 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
// netdev key
if (std::any_of(netKeys.cbegin(), netKeys.cend(), [&used](auto &key) { return used.contains(key); }))
used << "netdev";
// HACK append dummy if there are no other keys. This hack is required
// because empty list leads to the same behaviour as skip checking
if (used.isEmpty())
used << "dummy";
// gpu memory keys
static auto gpuMemoryCalculatedRegExp = QRegularExpression("^gpu(mem|freemb|freegb)");
for (auto key : _keys.filter(gpuMemoryCalculatedRegExp)) {
auto index = key.remove(gpuMemoryCalculatedRegExp);
used << QString("gpuusedmb%1").arg(index) << QString("gputotmb%1").arg(index)
<< QString("gpuusedgb%1").arg(index) << QString("gputotgb%1").arg(index);
}
return used.values();
}

View File

@@ -85,6 +85,13 @@ QStringList AWKeyOperations::dictKeys() const
// gpu
for (auto i = 0; i < m_devices.gpu.count(); ++i) {
allKeys.append(QString("gpu%1").arg(i));
allKeys.append(QString("gpumem%1").arg(i));
allKeys.append(QString("gpufreemb%1").arg(i));
allKeys.append(QString("gpufreegb%1").arg(i));
allKeys.append(QString("gputotmb%1").arg(i));
allKeys.append(QString("gputotgb%1").arg(i));
allKeys.append(QString("gpuusedmb%1").arg(i));
allKeys.append(QString("gpuusedgb%1").arg(i));
allKeys.append(QString("gputemp%1").arg(i));
}
// hdd

View File

@@ -248,6 +248,19 @@ void AWKeys::calculateValues()
m_values["uptotkb"] = m_values[QString("uptotkb%1").arg(netIndex)];
m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)];
// gpu memory keys
m_values["gpufreemb"] = m_values["gputotmb"].toLongLong() - m_values["gpuusedmb"].toLongLong();
m_values["gpufreegb"] = m_values["gputotgb"].toDouble() - m_values["gpuusedgb"].toDouble();
m_values["gpumem"] = 100.0 * m_values["gpuusedmb"].toDouble() / m_values["gputotmb"].toDouble();
for (auto i = 0; i < devices.gpu.count(); ++i) {
m_values[QString("gpufreemb%1").arg(i)] = m_values[QString("gputotmb%1").arg(i)].toLongLong()
- m_values[QString("gpuusedmb%1").arg(i)].toLongLong();
m_values[QString("gpufreegb%1").arg(i)]
= m_values[QString("gputotgb%1").arg(i)].toDouble() - m_values[QString("gpuusedgb%1").arg(i)].toDouble();
m_values[QString("gpumem%1").arg(i)] = 100.0 * m_values[QString("gpuusedmb%1").arg(i)].toDouble()
/ m_values[QString("gputotmb%1").arg(i)].toDouble();
}
// user defined keys
for (auto &key : m_keyOperator->userKeys())
m_values[key] = m_values[m_keyOperator->userKeySource(key)];

View File

@@ -15,6 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginformatterac.h"
#include "awpluginformattercustom.h"
#include "awpluginformatterdouble.h"

View File

@@ -0,0 +1,36 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awpluginmatchergpumemorytotal.h"
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUMemoryTotal::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{
return {
{"gputotmb", AWPluginFormatterMemoryMB::instance()},
{"gputotgb", AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryTotal::matches(const QString &_source) const
{
return _source == "gpu/all/totalVram";
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryTotal : public AWPluginMatcher<AWPluginMatcherGPUMemoryTotal>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,44 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awpluginmatchergpumemorytotalcore.h"
#include <QRegularExpression>
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *>
AWPluginMatcherGPUMemoryTotalCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{
auto index = AWPluginMatcher::index(_source, _settings.gpu);
if (index == -1)
return {};
return {
{QString("gputotmb%1").arg(index), AWPluginFormatterMemoryMB::instance()},
{QString("gputotgb%1").arg(index), AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryTotalCore::matches(const QString &_source) const
{
static auto regexp = QRegularExpression("^gpu/gpu.*/totalVram$");
return _source.contains(regexp);
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryTotalCore : public AWPluginMatcher<AWPluginMatcherGPUMemoryTotalCore>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,36 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awpluginmatchergpumemoryused.h"
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *> AWPluginMatcherGPUMemoryUsed::keys(const QString &, const KSysGuard::Unit,
const AWPluginMatcherSettings &) const
{
return {
{"gpuusedmb", AWPluginFormatterMemoryMB::instance()},
{"gpuusedgb", AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryUsed::matches(const QString &_source) const
{
return _source == "gpu/all/usedVram";
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryUsed : public AWPluginMatcher<AWPluginMatcherGPUMemoryUsed>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *> keys(const QString &, KSysGuard::Unit,
const AWPluginMatcherSettings &) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -0,0 +1,44 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awpluginmatchergpumemoryusedcore.h"
#include <QRegularExpression>
#include "formatters/formatters.h"
QHash<QString, AWPluginFormaterInterface *>
AWPluginMatcherGPUMemoryUsedCore::keys(const QString &_source, const KSysGuard::Unit,
const AWPluginMatcherSettings &_settings) const
{
auto index = AWPluginMatcher::index(_source, _settings.gpu);
if (index == -1)
return {};
return {
{QString("gpuusedmb%1").arg(index), AWPluginFormatterMemoryMB::instance()},
{QString("gpuusedgb%1").arg(index), AWPluginFormatterMemoryGB::instance()},
};
}
bool AWPluginMatcherGPUMemoryUsedCore::matches(const QString &_source) const
{
static auto regexp = QRegularExpression("^gpu/gpu.*/usedVram$");
return _source.contains(regexp);
}

View File

@@ -0,0 +1,29 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginmatcher.h"
class AWPluginMatcherGPUMemoryUsedCore : public AWPluginMatcher<AWPluginMatcherGPUMemoryUsedCore>
{
public:
[[nodiscard]] QHash<QString, AWPluginFormaterInterface *>
keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override;
[[nodiscard]] bool matches(const QString &_source) const override;
};

View File

@@ -15,6 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#include "awpluginmatcherac.h"
#include "awpluginmatcherbattery.h"
#include "awpluginmatcherbrightness.h"
@@ -28,6 +30,10 @@
#include "awpluginmatcherdesktopnumber.h"
#include "awpluginmatchergpu.h"
#include "awpluginmatchergpucore.h"
#include "awpluginmatchergpumemorytotal.h"
#include "awpluginmatchergpumemorytotalcore.h"
#include "awpluginmatchergpumemoryused.h"
#include "awpluginmatchergpumemoryusedcore.h"
#include "awpluginmatchergputemperature.h"
#include "awpluginmatcherhdd.h"
#include "awpluginmatcherhddfree.h"
@@ -80,6 +86,10 @@ static QList<AWPluginMatcherInterface *> matchers = {
AWPluginMatcherDesktopNumber::instance(),
AWPluginMatcherGPU::instance(),
AWPluginMatcherGPUCore::instance(),
AWPluginMatcherGPUMemoryTotal::instance(),
AWPluginMatcherGPUMemoryTotalCore::instance(),
AWPluginMatcherGPUMemoryUsed::instance(),
AWPluginMatcherGPUMemoryUsedCore::instance(),
AWPluginMatcherGPUTemperature::instance(),
AWPluginMatcherHDD::instance(),
AWPluginMatcherHDDFree::instance(),

View File

@@ -19,7 +19,7 @@
"Id": "org.kde.plasma.desktoppanel",
"License": "GPLv3",
"Name": "Desktop Panel",
"Version": "4.0.5",
"Version": "4.1.0",
"Website": "https://arcanis.me/projects/awesome-widgets/"
},
"X-Plasma-API-Minimum-Version": "6.0"

View File

@@ -70,6 +70,13 @@ static const char STATIC_KEYS[] = "time,"
"cpucl,"
"cpu,"
"gpu,"
"gpumem,"
"gpufreemb,"
"gpufreegb,"
"gputotmb,"
"gputotgb,"
"gpuusedmb,"
"gpuusedgb,"
"memmb,"
"memgb,"
"memfreemb,"