diff --git a/sources/awesome-widget/plugin/CMakeLists.txt b/sources/awesome-widget/plugin/CMakeLists.txt index 866a8db..3532b0b 100644 --- a/sources/awesome-widget/plugin/CMakeLists.txt +++ b/sources/awesome-widget/plugin/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${Kf6_INCLUDE} ) -file(GLOB SUBPROJECT_SOURCE *.cpp formatters/*.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp) +file(GLOB SUBPROJECT_SOURCE *.cpp formatters/*.cpp matchers/*.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp) file(GLOB SUBPROJECT_UI *.ui) file(GLOB SUBPROJECT_NOTIFY *.notifyrc) diff --git a/sources/awesome-widget/plugin/awdataenginemapper.cpp b/sources/awesome-widget/plugin/awdataenginemapper.cpp index fa4db54..a3bef4f 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.cpp +++ b/sources/awesome-widget/plugin/awdataenginemapper.cpp @@ -22,6 +22,7 @@ #include "awdebug.h" #include "awformatterhelper.h" #include "formatters/formatters.h" +#include "matchers/matchers.h" AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_custom) @@ -77,116 +78,22 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy qCDebug(LOG_AW) << "Source" << _source << "with units" << _units; // regular expressions - static auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$"); - static auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$"); static auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$"); - static auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$"); - static auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$"); - static auto hddrRegExp = QRegularExpression("^disk/.*/read$"); - static auto hddwRegExp = QRegularExpression("^disk/.*/write$"); static auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$"); static auto mountFreeRegExp = QRegularExpression("^disk/.*/free$"); static auto mountUsedRegExp = QRegularExpression("^disk/.*/used$"); static auto netRegExp = QRegularExpression("^network/.*/(download|upload)$"); static auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$"); - if (_source == "extsysmon/battery/ac") { - // AC - m_map.insert(_source, "ac"); - m_formatter["ac"] = AWPluginFormatterAC::instance(); - } else if (_source.startsWith("extsysmon/battery/")) { - // battery stats - auto key = _source; - key.remove("extsysmon/battery/"); - m_map.insert(_source, key); - if (_source.contains("rate")) - m_formatter[key] = AWPluginFormatterFloat::instance(); - else - m_formatter[key] = AWPluginFormatterIntegerShort::instance(); - } else if (_source == "cpu/all/usage") { - // cpu - m_map.insert(_source, "cpu"); - m_formatter["cpu"] = AWPluginFormatterFloat::instance(); - } else if (_source.contains(cpuRegExp)) { - // cpus - auto key = _source; - key.remove("cpu/").remove("/usage"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterFloat::instance(); - } else if (_source == "cpu/all/averageFrequency") { - // cpucl - m_map.insert(_source, "cpucl"); - m_formatter["cpucl"] = AWPluginFormatterInteger::instance(); - } else if (_source.contains(cpuclRegExp)) { - // cpucls - auto key = _source; - key.remove("cpu/cpu").remove("/frequency"); - key = QString("cpucl%1").arg(key); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterInteger::instance(); - } else if (_source.startsWith("extsysmon/custom")) { - // custom - auto key = _source; - key.remove("extsysmon/custom/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/desktop/name") { - // current desktop name - m_map.insert(_source, "desktop"); - m_formatter["desktop"] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/desktop/number") { - // current desktop number - m_map.insert(_source, "ndesktop"); - m_formatter["ndesktop"] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/desktop/count") { - // desktop count - m_map.insert(_source, "tdesktops"); - m_formatter["tdesktops"] = AWPluginFormatterNoFormat::instance(); - } else if (_source.contains(hddrRegExp)) { - // read speed - auto device = _source; - device.remove("disk/").remove("/read"); - auto index = m_devices["disk"].indexOf(device); - if (index > -1) { - QString key = QString("hddr%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemory::instance(); - } - } else if (_source.contains(hddwRegExp)) { - // write speed - auto device = _source; - device.remove("disk/").remove("/write"); - auto index = m_devices["disk"].indexOf(device); - if (index > -1) { - QString key = QString("hddw%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemory::instance(); - } - } else if (_source == "gpu/all/usage") { - // gpu load - m_map.insert(_source, "gpu"); - m_formatter["gpu"] = AWPluginFormatterFloat::instance(); - } else if (_source.contains(gpuRegExp)) { - // gpus - auto device = _source; - device.remove("gpu/").remove("/usage"); - auto index = m_devices["gpu"].indexOf(device); - if (index > -1) { - auto key = QString("gpu%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterFloat::instance(); - } - } else if (_source.contains(gpuTempRegExp)) { - // gpus temps - auto device = _source; - device.remove("gpu/").remove("/temperature"); - auto index = m_devices["gpu"].indexOf(device); - if (index > -1) { - auto key = QString("gputemp%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterTemperature::instance(); - } - } else if (_source.contains(mountFillRegExp)) { + auto matchers = AWPluginMatchers::matchers; + auto matcher = std::find_if(matchers.cbegin(), matchers.cend(), [&_source](auto matcher) { return matcher->matches(_source); }); + if (matcher == std::end(matchers)) + return {}; + + auto foundKeys = (*matcher)->keys(_source, _units, m_settings); + auto keys = foundKeys.keys(); // speedup a little bit + + if (_source.contains(mountFillRegExp)) { // fill level auto device = _source; device.remove("disk/").remove("/usedPercent"); @@ -229,45 +136,6 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy m_map.insert(_source, key); m_formatter[key] = AWPluginFormatterMemoryGB::instance(); } - } else if (_source.startsWith("cpu/loadaverages/loadaverage")) { - // load average - auto time = _source; - time.remove("cpu/loadaverages/loadaverage"); - auto key = QString("la%1").arg(time); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterFloatPrecise::instance(); - } else if (_source == "memory/physical/application") { - // app memory - // mb - m_map.insert(_source, "memmb"); - m_formatter["memmb"] = AWPluginFormatterMemoryMB::instance(); - // gb - m_map.insert(_source, "memgb"); - m_formatter["memgb"] = AWPluginFormatterMemoryGB::instance(); - } else if (_source == "memory/physical/free") { - // free memory - // mb - m_map.insert(_source, "memfreemb"); - m_formatter["memfreemb"] = AWPluginFormatterMemoryMB::instance(); - // gb - m_map.insert(_source, "memfreegb"); - m_formatter["memfreegb"] = AWPluginFormatterMemoryGB::instance(); - } else if (_source == "memory/physical/used") { - // used memory - // mb - m_map.insert(_source, "memusedmb"); - m_formatter["memusedmb"] = AWPluginFormatterMemoryMB::instance(); - // gb - m_map.insert(_source, "memusedgb"); - m_formatter["memusedgb"] = AWPluginFormatterMemoryGB::instance(); - } else if (_source == "extsysmon/network/device") { - // network device - m_map.insert(_source, "netdev"); - m_formatter["netdev"] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/network/ssid") { - // current ssid - m_map.insert(_source, "ssid"); - m_formatter["ssid"] = AWPluginFormatterNoFormat::instance(); } else if (_source.startsWith("extsysmon/requests/response")) { // network response auto key = _source; @@ -416,37 +284,36 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy m_formatter[key] = AWPluginFormatterTemperature::instance(); } - auto foundKeys = keysFromSource(_source); - // rewrite formatters for custom ones QStringList customFormattersKeys; if (m_customFormatters) customFormattersKeys = m_customFormatters->definedFormatters(); - qCInfo(LOG_AW) << "Looking for formatters" << foundKeys << "in" << customFormattersKeys; - for (auto &key : foundKeys) { + qCInfo(LOG_AW) << "Looking for formatters" << keys << "in" << customFormattersKeys; + for (auto &key : keys) { if (!customFormattersKeys.contains(key)) continue; - m_formatter[key] = AWPluginFormatterCustom::instance(); + foundKeys[key] = AWPluginFormatterCustom::instance(); } - // drop key from dictionary if no one user requested key required it - qCInfo(LOG_AW) << "Looking for keys" << foundKeys << "in" << _keys; - auto required = _keys.isEmpty() || std::any_of(foundKeys.cbegin(), foundKeys.cend(), [&_keys](auto &key) { + // check if keys were actually requested + qCInfo(LOG_AW) << "Looking for keys" << keys << "in" << _keys; + auto required = _keys.isEmpty() || std::any_of(keys.cbegin(), keys.cend(), [&_keys](auto &key) { return _keys.contains(key); }); - if (!required) { - m_map.remove(_source); - for (auto &key : foundKeys) - m_formatter.remove(key); + if (!required) + return {}; + + // insert keys into memory + for (auto [key, formatter] : foundKeys.asKeyValueRange()) { + m_map.insert(_source, key); + m_formatter[key] = formatter; } - return keysFromSource(_source); + return keys; } -void AWDataEngineMapper::setDevices(const QHash &_devices) +void AWDataEngineMapper::setDevices(const AWPluginMatcherSettings &_settings) { - qCDebug(LOG_AW) << "Devices" << _devices; - - m_devices = _devices; + m_settings = _settings; } diff --git a/sources/awesome-widget/plugin/awdataenginemapper.h b/sources/awesome-widget/plugin/awdataenginemapper.h index 72c5ebe..8a069e1 100644 --- a/sources/awesome-widget/plugin/awdataenginemapper.h +++ b/sources/awesome-widget/plugin/awdataenginemapper.h @@ -23,6 +23,7 @@ #include #include "formatters/awpluginformatter.h" +#include "matchers/awpluginmatchersettings.h" class AWFormatterHelper; @@ -39,10 +40,11 @@ public: [[nodiscard]] QStringList keysFromSource(const QString &_source) const; // set methods QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys); - void setDevices(const QHash &_devices); + void setDevices(const AWPluginMatcherSettings &_settings); private: AWFormatterHelper *m_customFormatters = nullptr; + AWPluginMatcherSettings m_settings; // variables QHash m_devices; QHash m_formatter; diff --git a/sources/awesome-widget/plugin/awkeycache.cpp b/sources/awesome-widget/plugin/awkeycache.cpp index 0ac191c..d828f63 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -146,18 +146,26 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL } -QHash AWKeyCache::loadKeysFromCache() +AWPluginMatcherSettings AWKeyCache::loadKeysFromCache() { auto fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); qCInfo(LOG_AW) << "Cache file" << fileName; QSettings cache(fileName, QSettings::IniFormat); - QHash devices; - for (auto &group : cache.childGroups()) { + AWPluginMatcherSettings devices; + QHash groups = { + {"disk", &devices.disk}, + {"gpu", &devices.gpu}, + {"mount", &devices.mount}, + {"net", &devices.network}, + {"temp", &devices.sensors}, + }; + + for (auto [group, list] : groups.asKeyValueRange()) { cache.beginGroup(group); for (auto &key : cache.allKeys()) - devices[group].append(cache.value(key).toString()); + list->append(cache.value(key).toString()); cache.endGroup(); } diff --git a/sources/awesome-widget/plugin/awkeycache.h b/sources/awesome-widget/plugin/awkeycache.h index bd32388..099639d 100644 --- a/sources/awesome-widget/plugin/awkeycache.h +++ b/sources/awesome-widget/plugin/awkeycache.h @@ -17,15 +17,16 @@ #pragma once -#include #include #include +#include + namespace AWKeyCache { bool addKeyToCache(const QString &_type, const QString &_key = ""); QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars, const QVariantMap &_tooltip, const QStringList &_userKeys, const QStringList &_allKeys); -QHash loadKeysFromCache(); +AWPluginMatcherSettings loadKeysFromCache(); } // namespace AWKeyCache diff --git a/sources/awesome-widget/plugin/awkeyoperations.cpp b/sources/awesome-widget/plugin/awkeyoperations.cpp index bb60147..33e34ac 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.cpp +++ b/sources/awesome-widget/plugin/awkeyoperations.cpp @@ -49,15 +49,7 @@ AWKeyOperations::AWKeyOperations(QObject *_parent) } -QStringList AWKeyOperations::devices(const QString &_type) const -{ - qCDebug(LOG_AW) << "Looking for type" << _type; - - return m_devices[_type]; -} - - -QHash AWKeyOperations::devices() const +AWPluginMatcherSettings AWKeyOperations::devices() const { return m_devices; } @@ -88,15 +80,15 @@ QStringList AWKeyOperations::dictKeys() const allKeys.append(QString("cpu%1").arg(i)); } // temperature - for (auto i = 0; i < m_devices["temp"].count(); ++i) + for (auto i = 0; i < m_devices.sensors.count(); ++i) allKeys.append(QString("temp%1").arg(i)); // gpu - for (auto i = 0; i < m_devices["gpu"].count(); ++i) { + for (auto i = 0; i < m_devices.gpu.count(); ++i) { allKeys.append(QString("gpu%1").arg(i)); allKeys.append(QString("gputemp%1").arg(i)); } // hdd - for (auto i = 0; i < m_devices["mount"].count(); ++i) { + for (auto i = 0; i < m_devices.mount.count(); ++i) { allKeys.append(QString("hddmb%1").arg(i)); allKeys.append(QString("hddgb%1").arg(i)); allKeys.append(QString("hddfreemb%1").arg(i)); @@ -106,12 +98,12 @@ QStringList AWKeyOperations::dictKeys() const allKeys.append(QString("hdd%1").arg(i)); } // hdd speed - for (auto i = 0; i < m_devices["disk"].count(); ++i) { + for (auto i = 0; i < m_devices.disk.count(); ++i) { allKeys.append(QString("hddr%1").arg(i)); allKeys.append(QString("hddw%1").arg(i)); } // network - for (auto i = 0; i < m_devices["net"].count(); ++i) { + for (auto i = 0; i < m_devices.network.count(); ++i) { allKeys.append(QString("downunits%1").arg(i)); allKeys.append(QString("upunits%1").arg(i)); allKeys.append(QString("downtotkb%1").arg(i)); @@ -224,15 +216,15 @@ QString AWKeyOperations::infoByKey(const QString &_key) const } else if (_key.contains(hddrwRegExp)) { auto index = _key; index.remove(hddrwRegExp); - output = m_devices["disk"][index.toInt()]; + output = m_devices.disk[index.toInt()]; } else if (_key.contains(hddMatchRegExp)) { auto index = _key; index.remove(hddRegExp); - output = m_devices["mount"][index.toInt()]; + output = m_devices.mount[index.toInt()]; } else if (_key.contains(netMatchRegExp)) { auto index = _key; index.remove(netRegExp); - output = m_devices["net"][index.toInt()]; + output = m_devices.network[index.toInt()]; } else if (_key.startsWith("pkgcount")) { auto item = m_extUpgrade->itemByTag(_key, stripped); if (item) @@ -248,7 +240,7 @@ QString AWKeyOperations::infoByKey(const QString &_key) const } else if (_key.startsWith("temp")) { auto index = _key; index.remove("temp"); - output = m_devices["temp"][index.toInt()]; + output = m_devices.sensors[index.toInt()]; } else if (_key.startsWith("response")) { auto item = m_extNetRequest->itemByTag(_key, stripped); if (item) diff --git a/sources/awesome-widget/plugin/awkeyoperations.h b/sources/awesome-widget/plugin/awkeyoperations.h index c9b028c..f239f2e 100644 --- a/sources/awesome-widget/plugin/awkeyoperations.h +++ b/sources/awesome-widget/plugin/awkeyoperations.h @@ -20,6 +20,7 @@ #include #include "extitemaggregator.h" +#include "matchers/awpluginmatchersettings.h" class AWCustomKeysHelper; @@ -38,8 +39,7 @@ class AWKeyOperations : public QObject public: explicit AWKeyOperations(QObject *_parent = nullptr); ~AWKeyOperations() override = default; - [[nodiscard]] QStringList devices(const QString &_type) const; - [[nodiscard]] QHash devices() const; + [[nodiscard]] AWPluginMatcherSettings devices() const; void updateCache(); // keys [[nodiscard]] QStringList dictKeys() const; @@ -73,6 +73,6 @@ private: ExtItemAggregator *m_extUpgrade = nullptr; ExtItemAggregator *m_extWeather = nullptr; // variables - QHash m_devices; + AWPluginMatcherSettings m_devices; QString m_pattern; }; diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index dfe270f..80a3131 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -231,14 +231,14 @@ void AWKeys::updateTextData() // specified pattern. Usually they are values which depend on several others void AWKeys::calculateValues() { + auto devices = m_keyOperator->devices(); + // hddtot* - auto mountDevices = m_keyOperator->devices("mount"); - for (auto &device : mountDevices) { - auto index = mountDevices.indexOf(device); - m_values[QString("hddtotmb%1").arg(index)] = m_values[QString("hddfreemb%1").arg(index)].toDouble() - + m_values[QString("hddmb%1").arg(index)].toDouble(); - m_values[QString("hddtotgb%1").arg(index)] = m_values[QString("hddfreegb%1").arg(index)].toDouble() - + m_values[QString("hddgb%1").arg(index)].toDouble(); + for (auto i = 0; i < devices.mount.count(); ++i) { + m_values[QString("hddtotmb%1").arg(i)] = m_values[QString("hddfreemb%1").arg(i)].toDouble() + + m_values[QString("hddmb%1").arg(i)].toDouble(); + m_values[QString("hddtotgb%1").arg(i)] = m_values[QString("hddfreegb%1").arg(i)].toDouble() + + m_values[QString("hddgb%1").arg(i)].toDouble(); } // memtot* @@ -248,7 +248,7 @@ void AWKeys::calculateValues() m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble(); // up, down, upkb, downkb, upunits, downunits - auto netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString()); + auto netIndex = devices.network.indexOf(m_values["netdev"].toString()); m_values["down"] = m_values[QString("down%1").arg(netIndex)]; m_values["downkb"] = m_values[QString("downkb%1").arg(netIndex)]; m_values["downtot"] = m_values[QString("downtot%1").arg(netIndex)]; diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index ebcad5b..3a02fce 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -128,11 +128,9 @@ void AWKeysAggregator::setCustomUptime(const QString &_customUptime) } -void AWKeysAggregator::setDevices(const QHash &_devices) +void AWKeysAggregator::setDevices(const AWPluginMatcherSettings &_settings) { - qCDebug(LOG_AW) << "Devices" << _devices; - - m_mapper->setDevices(_devices); + m_mapper->setDevices(_settings); } diff --git a/sources/awesome-widget/plugin/awkeysaggregator.h b/sources/awesome-widget/plugin/awkeysaggregator.h index f51dca1..b988e5e 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.h +++ b/sources/awesome-widget/plugin/awkeysaggregator.h @@ -23,6 +23,7 @@ #include #include "formatters/awpluginformatsettings.h" +#include "matchers/awpluginmatchersettings.h" class AWDataEngineMapper; @@ -56,7 +57,7 @@ public: void setAcOnline(const QString &_active); void setCustomTime(const QString &_customTime); void setCustomUptime(const QString &_customUptime); - void setDevices(const QHash &_devices); + void setDevices(const AWPluginMatcherSettings &_settings); void setTempUnits(const QString &_units); void setTranslate(bool _translate); diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcher.h b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h new file mode 100644 index 0000000..0037502 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * 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 + +#include + +#include + +#include "awpluginmatchersettings.h" + + +class AWPluginFormaterInterface; + +class AWPluginMatcherInterface { +public: + virtual ~AWPluginMatcherInterface() = default; + [[nodiscard]] virtual QHash keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) const = 0; + [[nodiscard]] virtual bool matches(const QString &_source) const = 0; +}; + + +template class AWPluginMatcher : public AWPluginMatcherInterface { + +public: + AWPluginMatcher(AWPluginMatcher &) = delete; + void operator=(const AWPluginMatcher &) = delete; + + static Matcher *instance() + { + static auto instance = std::make_unique(); + return instance.get(); + }; + +protected: + AWPluginMatcher() = default; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp new file mode 100644 index 0000000..766dd1b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatcherac.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherAC::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"ac", AWPluginFormatterAC::instance()}}; +} + + +bool AWPluginMatcherAC::matches(const QString &_source) const +{ + return _source == "extsysmon/battery/ac"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h new file mode 100644 index 0000000..ee0dedd --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherAC : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp new file mode 100644 index 0000000..0a3f382 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * 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 "awpluginmatcherbattery.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherBattery::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/battery/"); + + if (key.contains("rate")) + return {{key, AWPluginFormatterFloat::instance()}}; + return {{key, AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherBattery::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/battery/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h new file mode 100644 index 0000000..86f1444 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherBattery : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp new file mode 100644 index 0000000..d3a662b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatchercpu.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPU::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"cpu", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherCPU::matches(const QString &_source) const +{ + return _source == "cpu/all/usage"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h new file mode 100644 index 0000000..aadc4c3 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherCPU : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp new file mode 100644 index 0000000..f45a365 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * 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 "awpluginmatchercpucore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("cpu/").remove("/usage"); + return {{key, AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherCPUCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/usage$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h new file mode 100644 index 0000000..05d944f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherCPUCore : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp new file mode 100644 index 0000000..6044087 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatchercpufrequency.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUFrequency::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"cpucl", AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherCPUFrequency::matches(const QString &_source) const +{ + return _source == "cpu/all/averageFrequency"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h new file mode 100644 index 0000000..9f7a3a4 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherCPUFrequency : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp new file mode 100644 index 0000000..6dcd987 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * 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 "awpluginmatchercpufrequencycore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCPUFrequencyCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto index = _source; + index.remove("cpu/cpu").remove("/frequency"); + return {{QString("cpucl%1").arg(index), AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherCPUFrequencyCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/frequency$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h new file mode 100644 index 0000000..80ff1f0 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherCPUFrequencyCore : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp new file mode 100644 index 0000000..3cd51fd --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * 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 "awpluginmatchercustom.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherCustom::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/custom/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherCustom::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/custom/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h new file mode 100644 index 0000000..0a3284a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherCustom : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp new file mode 100644 index 0000000..5c54769 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktop.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktop::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"desktop", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktop::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/name"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h new file mode 100644 index 0000000..537690b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherDesktop : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp new file mode 100644 index 0000000..0b67245 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktopcount.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktopCount::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"tdesktops", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktopCount::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/count"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h new file mode 100644 index 0000000..5cd756a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherDesktopCount : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp new file mode 100644 index 0000000..fd8c7d4 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatcherdesktopnumber.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherDesktopNumber::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"ndesktop", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherDesktopNumber::matches(const QString &_source) const +{ + return _source == "extsysmon/desktop/number"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h new file mode 100644 index 0000000..8b76779 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherDesktopNumber : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp new file mode 100644 index 0000000..ef89daf --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatchergpu.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherGPU::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"gpu", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherGPU::matches(const QString &_source) const +{ + return _source == "gpu/all/usage"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h new file mode 100644 index 0000000..7ae2d2e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherGPU : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp new file mode 100644 index 0000000..aa4e731 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * 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 "awpluginmatchergpucore.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherGPUCore::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const +{ + auto device = _source; + device.remove("gpu/").remove("/usage"); + + auto index = _settings.gpu.indexOf(device); + if (index == -1) + return {}; + return {{QString("gpu%1").arg(index), AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherGPUCore::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^gpu/gpu.*/usage$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h new file mode 100644 index 0000000..50caa36 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherGPUCore : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp new file mode 100644 index 0000000..b2ec9c5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * 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 "awpluginmatchergputemperature.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherGPUTemperature::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const +{ + auto device = _source; + device.remove("gpu/").remove("/temperature"); + + auto index = _settings.gpu.indexOf(device); + if (index == -1) + return {}; + return {{QString("gputemp%1").arg(index), AWPluginFormatterTemperature::instance()}}; +} + + +bool AWPluginMatcherGPUTemperature::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^gpu/gpu.*/temperature$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h new file mode 100644 index 0000000..48a91db --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherGPUTemperature : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp new file mode 100644 index 0000000..da1f060 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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 "awpluginmatcherhddread.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDRead::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const +{ + // read speed + auto device = _source; + device.remove("disk/").remove("/read"); + + auto index = _settings.disk.indexOf(device); + if (index == -1) + return {}; + return {{QString("hddr%1").arg(index), AWPluginFormatterMemory::instance()}}; +} + + +bool AWPluginMatcherHDDRead::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/read$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h new file mode 100644 index 0000000..e877ef2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherHDDRead : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp new file mode 100644 index 0000000..6aa82b3 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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 "awpluginmatcherhddwrite.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDWrite::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const +{ + // read speed + auto device = _source; + device.remove("disk/").remove("/write"); + + auto index = _settings.disk.indexOf(device); + if (index == -1) + return {}; + return {{QString("hddw%1").arg(index), AWPluginFormatterMemory::instance()}}; +} + + +bool AWPluginMatcherHDDWrite::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/write$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h new file mode 100644 index 0000000..09a0473 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherHDDWrite : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &_settings) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp new file mode 100644 index 0000000..c4bcefe --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * 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 "awpluginmatcherloadaverage.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherLoadAverage::keys(const QString &_source, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + auto time = _source; + time.remove("cpu/loadaverages/loadaverage"); + return {{QString("la%1").arg(time), AWPluginFormatterFloatPrecise::instance()}}; +} + + +bool AWPluginMatcherLoadAverage::matches(const QString &_source) const +{ + return _source.startsWith("cpu/loadaverages/loadaverage"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h new file mode 100644 index 0000000..7db30e9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherLoadAverage : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &_source, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp new file mode 100644 index 0000000..90967fc --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryapplication.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryApplication::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return { + {"memmb", AWPluginFormatterMemoryMB::instance()}, + {"memgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryApplication::matches(const QString &_source) const +{ + return _source == "memory/physical/application"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h new file mode 100644 index 0000000..ba1765c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherMemoryApplication : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp new file mode 100644 index 0000000..bec30a5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryfree.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryFree::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return { + {"memfreemb", AWPluginFormatterMemoryMB::instance()}, + {"memfreegb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryFree::matches(const QString &_source) const +{ + return _source == "memory/physical/free"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h new file mode 100644 index 0000000..eadb7e6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherMemoryFree : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp new file mode 100644 index 0000000..7e47939 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 "awpluginmatchermemoryused.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryUsed::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return { + {"memusedmb", AWPluginFormatterMemoryMB::instance()}, + {"memusedgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryUsed::matches(const QString &_source) const +{ + return _source == "memory/physical/used"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h new file mode 100644 index 0000000..399757f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherMemoryUsed : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp new file mode 100644 index 0000000..439b277 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatchernetworkdevice.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetworkDevice::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"netdev", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherNetworkDevice::matches(const QString &_source) const +{ + return _source == "extsysmon/network/device"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h new file mode 100644 index 0000000..8e8ec4a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherNetworkDevice : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp new file mode 100644 index 0000000..ef60626 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "awpluginmatchernetworkssid.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetworkSSID::keys(const QString &, const KSysGuard::Unit, const AWPluginMatcherSettings &) const +{ + return {{"ssid", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherNetworkSSID::matches(const QString &_source) const +{ + return _source == "extsysmon/network/ssid"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h new file mode 100644 index 0000000..ae5fe32 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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 AWPluginMatcherNetworkSSID : public AWPluginMatcher { + +public: + [[nodiscard]] QHash keys(const QString &, KSysGuard::Unit, const AWPluginMatcherSettings &) const override; + [[nodiscard]] bool matches(const QString &_source) const override; +}; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h b/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h new file mode 100644 index 0000000..b16c1fe --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersettings.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * 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 + + +struct AWPluginMatcherSettings { + // devices + QStringList disk; + QStringList gpu; + QStringList mount; + QStringList network; + QStringList sensors; +}; diff --git a/sources/awesome-widget/plugin/matchers/matchers.h b/sources/awesome-widget/plugin/matchers/matchers.h new file mode 100644 index 0000000..89d9780 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/matchers.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * 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 "awpluginmatcherac.h" +#include "awpluginmatcherbattery.h" +#include "awpluginmatchercpu.h" +#include "awpluginmatchercpucore.h" +#include "awpluginmatchercpufrequency.h" +#include "awpluginmatchercpufrequencycore.h" +#include "awpluginmatchercustom.h" +#include "awpluginmatcherdesktop.h" +#include "awpluginmatcherdesktopcount.h" +#include "awpluginmatcherdesktopnumber.h" +#include "awpluginmatchergpu.h" +#include "awpluginmatchergpucore.h" +#include "awpluginmatchergputemperature.h" +#include "awpluginmatcherhddread.h" +#include "awpluginmatcherhddwrite.h" +#include "awpluginmatcherloadaverage.h" +#include "awpluginmatchermemoryapplication.h" +#include "awpluginmatchermemoryfree.h" +#include "awpluginmatchermemoryused.h" +#include "awpluginmatchernetworkdevice.h" +#include "awpluginmatchernetworkssid.h" + + +namespace AWPluginMatchers { + static QList matchers = { + AWPluginMatcherAC::instance(), + AWPluginMatcherBattery::instance(), + AWPluginMatcherCPU::instance(), + AWPluginMatcherCPUCore::instance(), + AWPluginMatcherCPUFrequency::instance(), + AWPluginMatcherCPUFrequencyCore::instance(), + AWPluginMatcherCustom::instance(), + AWPluginMatcherDesktop::instance(), + AWPluginMatcherDesktopCount::instance(), + AWPluginMatcherDesktopNumber::instance(), + AWPluginMatcherGPU::instance(), + AWPluginMatcherGPUCore::instance(), + AWPluginMatcherGPUTemperature::instance(), + AWPluginMatcherHDDRead::instance(), + AWPluginMatcherHDDWrite::instance(), + AWPluginMatcherLoadAverage::instance(), + AWPluginMatcherMemoryApplication::instance(), + AWPluginMatcherMemoryFree::instance(), + AWPluginMatcherMemoryUsed::instance(), + AWPluginMatcherNetworkDevice::instance(), + AWPluginMatcherNetworkSSID::instance(), + }; +};