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..92b2d46 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) @@ -31,10 +32,6 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus qCDebug(LOG_AW) << __PRETTY_FUNCTION__; // default formatters - // memory - m_formatter["mem"] = AWPluginFormatterFloat::instance(); - m_formatter["memtotmb"] = AWPluginFormatterMemoryMB::instance(); - m_formatter["memtotgb"] = AWPluginFormatterMemoryGB::instance(); // network m_formatter["down"] = AWPluginFormatterNet::instance(); m_formatter["downkb"] = AWPluginFormatterMemory::instance(); @@ -46,10 +43,6 @@ AWDataEngineMapper::AWDataEngineMapper(QObject *_parent, AWFormatterHelper *_cus m_formatter["uptot"] = AWPluginFormatterMemoryMB::instance(); m_formatter["uptotkb"] = AWPluginFormatterMemory::instance(); m_formatter["upunits"] = AWPluginFormatterNetUnits::instance(); - // swap - m_formatter["swap"] = AWPluginFormatterFloat::instance(); - m_formatter["swaptotmb"] = AWPluginFormatterMemoryMB::instance(); - m_formatter["swaptotgb"] = AWPluginFormatterMemoryGB::instance(); } @@ -76,377 +69,44 @@ 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)$"); + auto matchers = AWPluginMatchers::matchers; + auto matcher = std::find_if(matchers.cbegin(), matchers.cend(), + [&_source](auto matcher) { return matcher->matches(_source); }); + if (matcher == matchers.cend()) + return {}; - 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)) { - // fill level - auto device = _source; - device.remove("disk/").remove("/usedPercent"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - auto key = QString("hdd%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterFloat::instance(); - // additional keys - m_formatter[QString("hddtotmb%1").arg(index)] = AWPluginFormatterMemoryMB::instance(); - m_formatter[QString("hddtotgb%1").arg(index)] = AWPluginFormatterMemoryGB::instance(); - } - } else if (_source.contains(mountFreeRegExp)) { - // free space - auto device = _source; - device.remove("disk/").remove("/free"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - // mb - auto key = QString("hddfreemb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemoryMB::instance(); - // gb - key = QString("hddfreegb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemoryGB::instance(); - } - } else if (_source.contains(mountUsedRegExp)) { - // used - auto device = _source; - device.remove("disk/").remove("/used"); - auto index = m_devices["mount"].indexOf(device); - if (index > -1) { - // mb - auto key = QString("hddmb%1").arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemoryMB::instance(); - // gb - key = QString("hddgb%1").arg(index); - 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; - key.remove("extsysmon/requests/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNoFormat::instance(); - } else if (_source.contains(netRegExp)) { - // network speed - auto type = _source.endsWith("download") ? "down" : "up"; - auto index = m_devices["net"].indexOf(_source.split('/')[1]); - if (index > -1) { - // kb - auto key = QString("%1kb%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemory::instance(); - // smart - key = QString("%1%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNet::instance(); - // units - key = QString("%1units%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNetUnits::instance(); - } - } else if (_source.contains(netTotalRegExp)) { - // network data total - auto type = _source.endsWith("Download") ? "down" : "up"; - auto index = m_devices["net"].indexOf(_source.split('/')[1]); - if (index > -1) { - // kb - auto key = QString("%1totkb%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemory::instance(); - // mb - key = QString("%1tot%2").arg(type).arg(index); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterMemoryMB::instance(); - } - } else if (_source.startsWith("extsysmon/upgrade")) { - // package manager - auto key = _source; - key.remove("extsysmon/upgrade/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterIntegerShort::instance(); - } else if (_source.startsWith("extsysmon/player")) { - // player - auto key = _source; - key.remove("extsysmon/player/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/ps/running") { - // running processes count - m_map.insert(_source, "pscount"); - m_formatter["pscount"] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/ps/list") { - // list of running processes - m_map.insert(_source, "ps"); - m_formatter["ps"] = AWPluginFormatterList::instance(); - } else if (_source == "extsysmon/ps/count") { - // total processes count - m_map.insert(_source, "pstot"); - m_formatter["pstot"] = AWPluginFormatterNoFormat::instance(); - } else if (_source.startsWith("extsysmon/quotes")) { - // quotes - auto key = _source; - key.remove("extsysmon/quotes/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterDouble::instance(); - } else if (_source == "memory/swap/free") { - // free swap - // mb - m_map.insert(_source, "swapfreemb"); - m_formatter["swapfreemb"] = AWPluginFormatterMemoryMB::instance(); - // gb - m_map.insert(_source, "swapfreegb"); - m_formatter["swapfreegb"] = AWPluginFormatterMemoryGB::instance(); - } else if (_source == "memory/swap/used") { - // used swap - // mb - m_map.insert(_source, "swapmb"); - m_formatter["swapmb"] = AWPluginFormatterMemoryMB::instance(); - // gb - m_map.insert(_source, "swapgb"); - m_formatter["swapgb"] = AWPluginFormatterMemoryGB::instance(); - } else if (_source.startsWith("lmsensors/") || _source.contains(cpuTempRegExp) - || _source == "cpu/all/averageTemperature") { - // temperature - auto index = m_devices["temp"].indexOf(_source); - // HACK on DE initialization there are no units key - if (_units == KSysGuard::UnitInvalid) - return QStringList({QString("temp%1").arg(index)}); - if (index > -1) { - auto key = QString("temp%1").arg(index); - m_map.insert(_source, key); - if (_units == KSysGuard::UnitCelsius) - m_formatter[key] = AWPluginFormatterTemperature::instance(); - else - m_formatter[key] = AWPluginFormatterInteger::instance(); - } - } else if (_source == "extsysmon/time/now") { - // time - m_map.insert(_source, "time"); - m_formatter["time"] = AWPluginFormatterTime::instance(); - // custom time - m_map.insert(_source, "ctime"); - m_formatter["ctime"] = AWPluginFormatterTimeCustom::instance(); - // ISO time - m_map.insert(_source, "isotime"); - m_formatter["isotime"] = AWPluginFormatterTimeISO::instance(); - // long time - m_map.insert(_source, "longtime"); - m_formatter["longtime"] = AWPluginFormatterTimeLong::instance(); - // short time - m_map.insert(_source, "shorttime"); - m_formatter["shorttime"] = AWPluginFormatterTimeShort::instance(); - // timestamp - m_map.insert(_source, "tstime"); - m_formatter["tstime"] = AWPluginFormatterNoFormat::instance(); - } else if (_source == "extsysmon/system/brightness") { - m_map.insert(_source, "brightness"); - m_formatter["brightness"] = AWPluginFormatterIntegerShort::instance(); - } else if (_source == "extsysmon/system/volume") { - m_map.insert(_source, "volume"); - m_formatter["volume"] = AWPluginFormatterIntegerShort::instance(); - } else if (_source == "os/system/uptime") { - // uptime - m_map.insert(_source, "uptime"); - m_formatter["uptime"] = AWPluginFormatterUptime::instance(); - } else if (_source.startsWith("extsysmon/weather/temperature")) { - // temperature - auto key = _source; - key.remove("extsysmon/weather/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterTemperature::instance(); - } else if (_source.startsWith("extsysmon/weather/")) { - // other weather - auto key = _source; - key.remove("extsysmon/weather/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterNoFormat::instance(); - } else if (_source.startsWith("extsysmon/load/load")) { - // load source - auto key = _source; - key.remove("extsysmon/load/"); - m_map.insert(_source, key); - m_formatter[key] = AWPluginFormatterTemperature::instance(); - } - - auto foundKeys = keysFromSource(_source); + auto foundKeys = (*matcher)->keys(_source, _units, m_settings); + auto keys = foundKeys.keys(); // speedup a little bit // 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) { - return _keys.contains(key); - }); - if (!required) { - m_map.remove(_source); - for (auto &key : foundKeys) - m_formatter.remove(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) + 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..491928f 100644 --- a/sources/awesome-widget/plugin/awkeycache.cpp +++ b/sources/awesome-widget/plugin/awkeycache.cpp @@ -82,47 +82,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL } } - // insert depending keys, refer to AWKeys::calculateValues() - // hddtotmb* - for (auto &key : _allKeys.filter(QRegularExpression("^hddtotmb"))) { - if (!used.contains(key)) - continue; - key.remove("hddtotmb"); - auto index = key.toInt(); - used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index); - } - // hddtotgb* - for (auto &key : _allKeys.filter(QRegularExpression("^hddtotgb"))) { - if (!used.contains(key)) - continue; - key.remove("hddtotgb"); - auto index = key.toInt(); - used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index); - } - // mem - if (used.contains("mem")) - used << "memmb" - << "memtotmb"; - // memtotmb - if (used.contains("memtotmb")) - used << "memusedmb" - << "memfreemb"; - // memtotgb - if (used.contains("memtotgb")) - used << "memusedgb" - << "memfreegb"; - // swap - if (used.contains("swap")) - used << "swapmb" - << "swaptotmb"; - // swaptotmb - if (used.contains("swaptotmb")) - used << "swapmb" - << "swapfreemb"; - // memtotgb - if (used.contains("swaptotgb")) - used << "swapgb" - << "swapfreegb"; + // insert keys which depend on others, refer to AWKeys::calculateValues() // network keys QStringList netKeys( {"up", "upkb", "uptot", "uptotkb", "upunits", "down", "downkb", "downtot", "downtotkb", "downunits"}); @@ -146,18 +106,23 @@ 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..18bedf9 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -231,24 +231,10 @@ void AWKeys::updateTextData() // specified pattern. Usually they are values which depend on several others void AWKeys::calculateValues() { - // 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(); - } - - // memtot* - m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong(); - m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble(); - // mem - m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble(); + auto devices = m_keyOperator->devices(); // 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)]; @@ -260,12 +246,6 @@ void AWKeys::calculateValues() m_values["uptotkb"] = m_values[QString("uptotkb%1").arg(netIndex)]; m_values["upunits"] = m_values[QString("upunits%1").arg(netIndex)]; - // swaptot* - m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong(); - m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble(); - // swap - m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble(); - // user defined keys for (auto &key : m_keyOperator->userKeys()) m_values[key] = m_values[m_keyOperator->userKeySource(key)]; 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..95d81a1 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; @@ -38,7 +39,6 @@ class AWKeysAggregator : public QObject Q_PROPERTY(bool translate READ translate WRITE setTranslate); public: - explicit AWKeysAggregator(QObject *_parent = nullptr); ~AWKeysAggregator() override = default; void initFormatters(); @@ -56,7 +56,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/formatters/awpluginformatter.h b/sources/awesome-widget/plugin/formatters/awpluginformatter.h index 7a47d09..02f7a3b 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatter.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatter.h @@ -25,15 +25,18 @@ #include "awpluginformatsettings.h" -class AWPluginFormaterInterface { +class AWPluginFormaterInterface +{ public: virtual ~AWPluginFormaterInterface() = default; - virtual QString format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const = 0; - virtual void load() {}; + virtual QString format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const + = 0; + virtual void load(){}; }; -template class AWPluginFormatter : public AWPluginFormaterInterface { +template class AWPluginFormatter : public AWPluginFormaterInterface +{ public: static constexpr double KBinBytes = 1024.0; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp index c0c33d7..9ddbcec 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterac.cpp @@ -18,7 +18,8 @@ #include "awpluginformatterac.h" -QString AWPluginFormatterAC::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterAC::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { return _value.toBool() ? _settings.acOnline : _settings.acOffline; } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterac.h b/sources/awesome-widget/plugin/formatters/awpluginformatterac.h index 54ebaad..221a4df 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterac.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterac.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterAC : public AWPluginFormatter { +class AWPluginFormatterAC : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp index 7858f3b..42b03e0 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.cpp @@ -20,7 +20,8 @@ #include "awformatterhelper.h" -QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterCustom::format(const QVariant &_value, const QString &_key, + const AWPluginFormatSettings &_settings) const { if (_settings.customFormatters) return _settings.customFormatters->convert(_value, _key); diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h index 2fab7ff..c815fa1 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattercustom.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterCustom : public AWPluginFormatter { +class AWPluginFormatterCustom : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &_key, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h index de8fdc7..4dc3f96 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterdouble.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterDouble : public AWPluginFormatter { +class AWPluginFormatterDouble : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h index fba42bf..09e99fd 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloat.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterFloat : public AWPluginFormatter{ +class AWPluginFormatterFloat : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp index bd8a222..90bab4a 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.cpp @@ -18,7 +18,8 @@ #include "awpluginformatterfloatprecise.h" -QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +QString AWPluginFormatterFloatPrecise::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const { return QString("%1").arg(_value.toDouble(), 5, 'f', 2); } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h index 18a638d..666cff0 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterfloatprecise.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterFloatPrecise : public AWPluginFormatter { +class AWPluginFormatterFloatPrecise : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h index 253e485..315605b 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterinteger.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterInteger : public AWPluginFormatter { +class AWPluginFormatterInteger : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp index 1d8db28..93da1be 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.cpp @@ -18,7 +18,8 @@ #include "awpluginformatterintegershort.h" -QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +QString AWPluginFormatterIntegerShort::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const { return QString("%1").arg(_value.toDouble(), 3, 'f', 0); } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h index 1b1aec7..5b4e12b 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegershort.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterIntegerShort : public AWPluginFormatter { +class AWPluginFormatterIntegerShort : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp index d27a56d..f0a3605 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.cpp @@ -18,7 +18,8 @@ #include "awpluginformatterintegerwide.h" -QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const +QString AWPluginFormatterIntegerWide::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &) const { return QString("%1").arg(_value.toDouble(), 5, 'f', 0); } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h index bcd5faa..8d5c4ef 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterintegerwide.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterIntegerWide : public AWPluginFormatter { +class AWPluginFormatterIntegerWide : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h index 3c53742..69dc46a 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatterlist.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterList : public AWPluginFormatter { +class AWPluginFormatterList : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h index bd9b53f..fcc4041 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemory.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterMemory : public AWPluginFormatter { +class AWPluginFormatterMemory : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h index 8819f87..a780632 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorygb.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterMemoryGB : public AWPluginFormatter { +class AWPluginFormatterMemoryGB : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h index f6e9866..2973db6 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattermemorymb.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterMemoryMB : public AWPluginFormatter { +class AWPluginFormatterMemoryMB : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternet.h b/sources/awesome-widget/plugin/formatters/awpluginformatternet.h index fd1b43f..1084732 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatternet.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternet.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterNet : public AWPluginFormatter { +class AWPluginFormatterNet : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp index b544641..f641654 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.cpp @@ -20,7 +20,8 @@ #include -QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterNetUnits::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { auto value = _value.toDouble(); return (value > MBinBytes) ? formatMB(_settings) : formatKB(_settings); diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h index 805e3e8..568e0c2 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternetunits.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterNetUnits : public AWPluginFormatter { +class AWPluginFormatterNetUnits : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h index 11cd5dc..983be3a 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatternoformat.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterNoFormat : public AWPluginFormatter { +class AWPluginFormatterNoFormat : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp index 35ecd89..a5e72a8 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.cpp @@ -18,7 +18,8 @@ #include "awpluginformattertemperature.h" -QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterTemperature::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { auto converted = convert(_value.toDouble(), _settings.tempUnits); return QString("%1").arg(converted, 5, 'f', 1); diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h index a2d6c07..473866c 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertemperature.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTemperature : public AWPluginFormatter { +class AWPluginFormatterTemperature : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertime.h b/sources/awesome-widget/plugin/formatters/awpluginformattertime.h index 06c0c9e..5b43b21 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertime.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertime.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTime : public AWPluginFormatter { +class AWPluginFormatterTime : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp index ada72b9..2aa6600 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.cpp @@ -20,7 +20,8 @@ #include "awdebug.h" -QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterTimeCustom::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { auto value = QDateTime::fromSecsSinceEpoch(_value.toLongLong()); return format(value, _settings.customTime, locale(_settings)); @@ -35,7 +36,8 @@ void AWPluginFormatterTimeCustom::load() } -QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString, const QLocale &_locale) const +QString AWPluginFormatterTimeCustom::format(const QDateTime &_value, QString _formatString, + const QLocale &_locale) const { for (auto &key : m_timeKeys) _formatString.replace(QString("$%1").arg(key), _locale.toString(_value, key)); diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h index c90ba50..ccd3621 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimecustom.h @@ -22,7 +22,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTimeCustom : public AWPluginFormatter { +class AWPluginFormatterTimeCustom : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h index 4309368..fa8e557 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeiso.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTimeISO : public AWPluginFormatter { +class AWPluginFormatterTimeISO : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp index aef6f5f..bcb64c0 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.cpp @@ -20,7 +20,8 @@ #include -QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterTimeLong::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::LongFormat); } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h index e80a060..3258d62 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimelong.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTimeLong : public AWPluginFormatter { +class AWPluginFormatterTimeLong : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp index e6c88b6..9bd0840 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.cpp @@ -20,7 +20,8 @@ #include -QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterTimeShort::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { return locale(_settings).toString(QDateTime::fromSecsSinceEpoch(_value.toLongLong()), QLocale::ShortFormat); } diff --git a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h index 7947bda..c99e8bd 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformattertimeshort.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterTimeShort : public AWPluginFormatter { +class AWPluginFormatterTimeShort : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp index 5073f10..9b614e2 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp +++ b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.cpp @@ -18,7 +18,8 @@ #include "awpluginformatteruptime.h" -QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const +QString AWPluginFormatterUptime::format(const QVariant &_value, const QString &, + const AWPluginFormatSettings &_settings) const { auto value = static_cast(_value.toDouble()); return format(value, _settings.customUptime); diff --git a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h index e0fdc1a..3ca0971 100644 --- a/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h +++ b/sources/awesome-widget/plugin/formatters/awpluginformatteruptime.h @@ -20,7 +20,8 @@ #include "awpluginformatter.h" -class AWPluginFormatterUptime : public AWPluginFormatter { +class AWPluginFormatterUptime : public AWPluginFormatter +{ public: QString format(const QVariant &_value, const QString &, const AWPluginFormatSettings &_settings) const override; diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcher.h b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h new file mode 100644 index 0000000..cf47581 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcher.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * 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(); + }; + + static QString device(const QString &_source) { return _source.split('/')[1]; }; + +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..672a2d6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..787af93 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherac.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 "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..d51ebb7 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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..a87a06e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbattery.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 "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/awpluginmatcherbrightness.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp new file mode 100644 index 0000000..f9494aa --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherbrightness.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherBrightness::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"brightness", AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherBrightness::matches(const QString &_source) const +{ + return _source == "extsysmon/system/brightness"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.h new file mode 100644 index 0000000..632c6c9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherbrightness.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 "awpluginmatcher.h" + + +class AWPluginMatcherBrightness : 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/awpluginmatchercpu.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp new file mode 100644 index 0000000..9e125fc --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..ba0dfe9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpu.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 "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..90086a2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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..829c25e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpucore.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 "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..585a17a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..2a522fa --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequency.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 "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..0f6d118 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * 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..83f3d55 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercpufrequencycore.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 "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..79ac843 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.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 "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..efdde9c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchercustom.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 "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..ab3a5ab --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..279afd5 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktop.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 "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..c7c00d2 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..d006198 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopcount.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 "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..e09873c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..3ddcaf4 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherdesktopnumber.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 "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..e46afa3 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..7fece4f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpu.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 "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..adbaa96 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.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 "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..dd0c287 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergpucore.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 "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..d28c5ae --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * 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..43ec092 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchergputemperature.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 "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/awpluginmatcherhdd.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.cpp new file mode 100644 index 0000000..ed0be29 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.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 "awpluginmatcherhdd.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDD::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto device = AWPluginMatcher::device(_source); + auto index = _settings.disk.indexOf(device); + + if (index == -1) + return {}; + return {{QString("hdd%1").arg(index), AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherHDD::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/usedPercent$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.h new file mode 100644 index 0000000..a59fef0 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhdd.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 "awpluginmatcher.h" + + +class AWPluginMatcherHDD : 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/awpluginmatcherhddfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp new file mode 100644 index 0000000..8f4381f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherhddfree.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDFree::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto device = AWPluginMatcher::device(_source); + auto index = _settings.disk.indexOf(device); + + if (index == -1) + return {}; + return { + {QString("hddfreemb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddfreegb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDFree::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/free$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.h new file mode 100644 index 0000000..9e6052e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddfree.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 "awpluginmatcher.h" + + +class AWPluginMatcherHDDFree : 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..11db01b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.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 "awpluginmatcherhddread.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDRead::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto device = AWPluginMatcher::device(_source); + 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..2b062b7 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddread.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 "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/awpluginmatcherhddtotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp new file mode 100644 index 0000000..53a9032 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * 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 "awpluginmatcherhddtotal.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherHDDTotal::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto device = AWPluginMatcher::device(_source); + auto index = _settings.disk.indexOf(device); + + if (index == -1) + return {}; + return { + {QString("hddtotmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddtotgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDTotal::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/total$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.h new file mode 100644 index 0000000..2df48c7 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddtotal.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 "awpluginmatcher.h" + + +class AWPluginMatcherHDDTotal : 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/awpluginmatcherhddused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp new file mode 100644 index 0000000..31d311e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherhddused.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherHDDUsed::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto device = AWPluginMatcher::device(_source); + auto index = _settings.disk.indexOf(device); + + if (index == -1) + return {}; + return { + {QString("hddmb%1").arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("hddgb%1").arg(index), AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherHDDUsed::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^disk/.*/used$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.h new file mode 100644 index 0000000..e3c9792 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddused.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 "awpluginmatcher.h" + + +class AWPluginMatcherHDDUsed : 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..61f775e --- /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 +{ + auto device = AWPluginMatcher::device(_source); + 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..cb849a7 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherhddwrite.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 "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/awpluginmatcherload.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.cpp new file mode 100644 index 0000000..e00e03a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.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 "awpluginmatcherload.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherLoad::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/load/"); + return {{key, AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherLoad::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/load/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherload.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.h new file mode 100644 index 0000000..4d121f6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherload.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 "awpluginmatcher.h" + + +class AWPluginMatcherLoad : 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/awpluginmatcherloadaverage.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.cpp new file mode 100644 index 0000000..b7e9c77 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.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 "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..4389b77 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherloadaverage.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 "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/awpluginmatchermemory.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp new file mode 100644 index 0000000..18b0f4c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchermemory.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemory::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"mem", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherMemory::matches(const QString &_source) const +{ + return _source == "memory/physical/usedPercent"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.h new file mode 100644 index 0000000..69c71d9 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemory.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 "awpluginmatcher.h" + + +class AWPluginMatcherMemory : 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/awpluginmatchermemoryapplication.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp new file mode 100644 index 0000000..18ba95f --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "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..a4d1940 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryapplication.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 "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..6107331 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "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..642cbef --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryfree.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 "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/awpluginmatchermemorytotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp new file mode 100644 index 0000000..6fa0e82 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatchermemorytotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherMemoryTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"memtotmb", AWPluginFormatterMemoryMB::instance()}, + {"memtotgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherMemoryTotal::matches(const QString &_source) const +{ + return _source == "memory/physical/total"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.h new file mode 100644 index 0000000..262602a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemorytotal.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 "awpluginmatcher.h" + + +class AWPluginMatcherMemoryTotal : 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..a7dae15 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "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..09ac7db --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchermemoryused.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 "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/awpluginmatchernetwork.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp new file mode 100644 index 0000000..1f7dc15 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + * 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 "awpluginmatchernetwork.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherNetwork::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto type = _source.endsWith("download") ? "down" : "up"; + auto device = AWPluginMatcher::device(_source); + auto index = _settings.network.indexOf(device); + + if (index == -1) + return {}; + + return { + {QString("%1%2").arg(type).arg(index), AWPluginFormatterNet::instance()}, + {QString("%1kb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, + {QString("%1units%2").arg(type).arg(index), AWPluginFormatterNetUnits::instance()}, + }; +} + + +bool AWPluginMatcherNetwork::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^network/.*/(download|upload)$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.h new file mode 100644 index 0000000..7ac5200 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetwork.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 "awpluginmatcher.h" + + +class AWPluginMatcherNetwork : 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/awpluginmatchernetworkdevice.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp new file mode 100644 index 0000000..c1675bd --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..eae282a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkdevice.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 "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..be60d37 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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..95d39d7 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworkssid.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 "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/awpluginmatchernetworktotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp new file mode 100644 index 0000000..5401b63 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + * 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 "awpluginmatchernetworktotal.h" + +#include + +#include "formatters/formatters.h" + + +QHash +AWPluginMatcherNetworkTotal::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &_settings) const +{ + auto type = _source.endsWith("Download") ? "down" : "up"; + auto device = AWPluginMatcher::device(_source); + auto index = _settings.network.indexOf(device); + + if (index == -1) + return {}; + + return { + {QString("%1tot%2").arg(type).arg(index), AWPluginFormatterMemoryMB::instance()}, + {QString("%1totkb%2").arg(type).arg(index), AWPluginFormatterMemory::instance()}, + }; +} + + +bool AWPluginMatcherNetworkTotal::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$"); + return _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.h new file mode 100644 index 0000000..8d328e6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchernetworktotal.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 "awpluginmatcher.h" + + +class AWPluginMatcherNetworkTotal : 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/awpluginmatcherplayer.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.cpp new file mode 100644 index 0000000..886d286 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.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 "awpluginmatcherplayer.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPlayer::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/player/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPlayer::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/player/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.h new file mode 100644 index 0000000..1a9eae1 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherplayer.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 "awpluginmatcher.h" + + +class AWPluginMatcherPlayer : 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/awpluginmatcherps.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp new file mode 100644 index 0000000..ed51258 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherps.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPS::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"pscount", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPS::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/running"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherps.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.h new file mode 100644 index 0000000..0b2ef0e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherps.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 "awpluginmatcher.h" + + +class AWPluginMatcherPS : 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/awpluginmatcherpsprocesses.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp new file mode 100644 index 0000000..195955c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherpsprocesses.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPSProcesses::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"ps", AWPluginFormatterList::instance()}}; +} + + +bool AWPluginMatcherPSProcesses::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/list"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.h new file mode 100644 index 0000000..879018b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpsprocesses.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 "awpluginmatcher.h" + + +class AWPluginMatcherPSProcesses : 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/awpluginmatcherpstotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp new file mode 100644 index 0000000..ab924c6 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherpstotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherPSTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"count", AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherPSTotal::matches(const QString &_source) const +{ + return _source == "extsysmon/ps/count"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.h new file mode 100644 index 0000000..f283def --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherpstotal.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 "awpluginmatcher.h" + + +class AWPluginMatcherPSTotal : 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/awpluginmatcherquotes.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.cpp new file mode 100644 index 0000000..e999597 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.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 "awpluginmatcherquotes.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherQuotes::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/quotes/"); + return {{key, AWPluginFormatterDouble::instance()}}; +} + + +bool AWPluginMatcherQuotes::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/quotes/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.h new file mode 100644 index 0000000..42bb836 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherquotes.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 "awpluginmatcher.h" + + +class AWPluginMatcherQuotes : 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/awpluginmatcherrequest.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.cpp new file mode 100644 index 0000000..f1d1932 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.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 "awpluginmatcherrequest.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherRequest::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/requests/"); + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherRequest::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/requests/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.h new file mode 100644 index 0000000..f9e0b74 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherrequest.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 "awpluginmatcher.h" + + +class AWPluginMatcherRequest : 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/awpluginmatchersensors.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp new file mode 100644 index 0000000..e1f7030 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * 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 "awpluginmatchersensors.h" + +#include + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSensors::keys(const QString &_source, KSysGuard::Unit _units, + const AWPluginMatcherSettings &_settings) const +{ + // temperature + auto index = _settings.sensors.indexOf(_source); + auto key = QString("temp%1").arg(index); + + if (index == -1) + return {}; + + if (_units == KSysGuard::UnitCelsius) + return {{key, AWPluginFormatterTemperature::instance()}}; + return {{key, AWPluginFormatterInteger::instance()}}; +} + + +bool AWPluginMatcherSensors::matches(const QString &_source) const +{ + static auto regexp = QRegularExpression("^cpu/cpu.*/temperature$"); + return _source.startsWith("lmsensors/") || _source == "cpu/all/averageTemperature" || _source.contains(regexp); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.h new file mode 100644 index 0000000..c2b878c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchersensors.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 "awpluginmatcher.h" + + +class AWPluginMatcherSensors : public AWPluginMatcher +{ + +public: + [[nodiscard]] QHash + keys(const QString &_source, KSysGuard::Unit _units, const AWPluginMatcherSettings &_settings) 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/awpluginmatcherswap.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp new file mode 100644 index 0000000..218013d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcherswap.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwap::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"swap", AWPluginFormatterFloat::instance()}}; +} + + +bool AWPluginMatcherSwap::matches(const QString &_source) const +{ + return _source == "memory/swap/usedPercent"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.h new file mode 100644 index 0000000..574657b --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswap.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 "awpluginmatcher.h" + + +class AWPluginMatcherSwap : 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/awpluginmatcherswapfree.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp new file mode 100644 index 0000000..a587111 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherswapfree.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapFree::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swapfreemb", AWPluginFormatterMemoryMB::instance()}, + {"swapfreegb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapFree::matches(const QString &_source) const +{ + return _source == "memory/swap/free"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.h new file mode 100644 index 0000000..c7dda8e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapfree.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 "awpluginmatcher.h" + + +class AWPluginMatcherSwapFree : 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/awpluginmatcherswaptotal.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp new file mode 100644 index 0000000..23198da --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherswaptotal.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapTotal::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swaptotmb", AWPluginFormatterMemoryMB::instance()}, + {"swaptotgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapTotal::matches(const QString &_source) const +{ + return _source == "memory/swap/total"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.h new file mode 100644 index 0000000..e632700 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswaptotal.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 "awpluginmatcher.h" + + +class AWPluginMatcherSwapTotal : 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/awpluginmatcherswapused.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp new file mode 100644 index 0000000..6c2430c --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "awpluginmatcherswapused.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherSwapUsed::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"swapmb", AWPluginFormatterMemoryMB::instance()}, + {"swapgb", AWPluginFormatterMemoryGB::instance()}, + }; +} + + +bool AWPluginMatcherSwapUsed::matches(const QString &_source) const +{ + return _source == "memory/swap/used"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.h new file mode 100644 index 0000000..51eea14 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherswapused.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 "awpluginmatcher.h" + + +class AWPluginMatcherSwapUsed : 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/awpluginmatchertime.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.cpp new file mode 100644 index 0000000..60764e0 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.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 "awpluginmatchertime.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherTime::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return { + {"time", AWPluginFormatterTime::instance()}, {"ctime", AWPluginFormatterTimeCustom::instance()}, + {"isotime", AWPluginFormatterTimeISO::instance()}, {"longtime", AWPluginFormatterTimeLong::instance()}, + {"shorttime", AWPluginFormatterTimeShort::instance()}, {"tstime", AWPluginFormatterNoFormat::instance()}, + }; +} + + +bool AWPluginMatcherTime::matches(const QString &_source) const +{ + return _source == "extsysmon/time/now"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchertime.h b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.h new file mode 100644 index 0000000..fb2829d --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchertime.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 "awpluginmatcher.h" + + +class AWPluginMatcherTime : 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/awpluginmatcherupgrade.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.cpp new file mode 100644 index 0000000..6e4985a --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.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 "awpluginmatcherupgrade.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherUpgrade::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/upgrade/"); + return {{key, AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherUpgrade::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/upgrade/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.h new file mode 100644 index 0000000..1e30945 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherupgrade.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 "awpluginmatcher.h" + + +class AWPluginMatcherUpgrade : 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/awpluginmatcheruptime.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp new file mode 100644 index 0000000..15b2561 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatcheruptime.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherUptime::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"uptime", AWPluginFormatterUptime::instance()}}; +} + + +bool AWPluginMatcherUptime::matches(const QString &_source) const +{ + return _source == "os/system/uptime"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.h new file mode 100644 index 0000000..78b9f88 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcheruptime.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 "awpluginmatcher.h" + + +class AWPluginMatcherUptime : 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/awpluginmatchervolume.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp new file mode 100644 index 0000000..6d92a1e --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + * 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 "awpluginmatchervolume.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherVolume::keys(const QString &, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + return {{"volume", AWPluginFormatterIntegerShort::instance()}}; +} + + +bool AWPluginMatcherVolume::matches(const QString &_source) const +{ + return _source == "extsysmon/system/volume"; +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.h new file mode 100644 index 0000000..21565ff --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatchervolume.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 "awpluginmatcher.h" + + +class AWPluginMatcherVolume : 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/awpluginmatcherweather.cpp b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp new file mode 100644 index 0000000..5ac7044 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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 "awpluginmatcherweather.h" + +#include "formatters/formatters.h" + + +QHash AWPluginMatcherWeather::keys(const QString &_source, const KSysGuard::Unit, + const AWPluginMatcherSettings &) const +{ + auto key = _source; + key.remove("extsysmon/weather/"); + + if (key.startsWith("temperature")) + return {{key, AWPluginFormatterTemperature::instance()}}; + return {{key, AWPluginFormatterNoFormat::instance()}}; +} + + +bool AWPluginMatcherWeather::matches(const QString &_source) const +{ + return _source.startsWith("extsysmon/weather/"); +} diff --git a/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.h new file mode 100644 index 0000000..4ed0877 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/awpluginmatcherweather.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 "awpluginmatcher.h" + + +class AWPluginMatcherWeather : 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/matchers.h b/sources/awesome-widget/plugin/matchers/matchers.h new file mode 100644 index 0000000..4545cd3 --- /dev/null +++ b/sources/awesome-widget/plugin/matchers/matchers.h @@ -0,0 +1,118 @@ +/*************************************************************************** + * 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 "awpluginmatcherbrightness.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 "awpluginmatcherhdd.h" +#include "awpluginmatcherhddfree.h" +#include "awpluginmatcherhddread.h" +#include "awpluginmatcherhddtotal.h" +#include "awpluginmatcherhddused.h" +#include "awpluginmatcherhddwrite.h" +#include "awpluginmatcherload.h" +#include "awpluginmatcherloadaverage.h" +#include "awpluginmatchermemory.h" +#include "awpluginmatchermemoryapplication.h" +#include "awpluginmatchermemoryfree.h" +#include "awpluginmatchermemorytotal.h" +#include "awpluginmatchermemoryused.h" +#include "awpluginmatchernetwork.h" +#include "awpluginmatchernetworkdevice.h" +#include "awpluginmatchernetworkssid.h" +#include "awpluginmatchernetworktotal.h" +#include "awpluginmatcherplayer.h" +#include "awpluginmatcherps.h" +#include "awpluginmatcherpsprocesses.h" +#include "awpluginmatcherpstotal.h" +#include "awpluginmatcherquotes.h" +#include "awpluginmatcherrequest.h" +#include "awpluginmatchersensors.h" +#include "awpluginmatcherswap.h" +#include "awpluginmatcherswapfree.h" +#include "awpluginmatcherswaptotal.h" +#include "awpluginmatcherswapused.h" +#include "awpluginmatchertime.h" +#include "awpluginmatcherupgrade.h" +#include "awpluginmatcheruptime.h" +#include "awpluginmatchervolume.h" +#include "awpluginmatcherweather.h" + + +namespace AWPluginMatchers +{ +static QList matchers = { + AWPluginMatcherAC::instance(), + AWPluginMatcherBattery::instance(), + AWPluginMatcherBrightness::instance(), + AWPluginMatcherCPU::instance(), + AWPluginMatcherCPUCore::instance(), + AWPluginMatcherCPUFrequency::instance(), + AWPluginMatcherCPUFrequencyCore::instance(), + AWPluginMatcherCustom::instance(), + AWPluginMatcherDesktop::instance(), + AWPluginMatcherDesktopCount::instance(), + AWPluginMatcherDesktopNumber::instance(), + AWPluginMatcherGPU::instance(), + AWPluginMatcherGPUCore::instance(), + AWPluginMatcherGPUTemperature::instance(), + AWPluginMatcherHDD::instance(), + AWPluginMatcherHDDFree::instance(), + AWPluginMatcherHDDRead::instance(), + AWPluginMatcherHDDTotal::instance(), + AWPluginMatcherHDDUsed::instance(), + AWPluginMatcherHDDWrite::instance(), + AWPluginMatcherLoad::instance(), + AWPluginMatcherLoadAverage::instance(), + AWPluginMatcherMemory::instance(), + AWPluginMatcherMemoryApplication::instance(), + AWPluginMatcherMemoryFree::instance(), + AWPluginMatcherMemoryTotal::instance(), + AWPluginMatcherMemoryUsed::instance(), + AWPluginMatcherNetwork::instance(), + AWPluginMatcherNetworkDevice::instance(), + AWPluginMatcherNetworkSSID::instance(), + AWPluginMatcherNetworkTotal::instance(), + AWPluginMatcherPlayer::instance(), + AWPluginMatcherPS::instance(), + AWPluginMatcherPSProcesses::instance(), + AWPluginMatcherPSTotal::instance(), + AWPluginMatcherQuotes::instance(), + AWPluginMatcherRequest::instance(), + AWPluginMatcherSensors::instance(), + AWPluginMatcherSwap::instance(), + AWPluginMatcherSwapFree::instance(), + AWPluginMatcherSwapTotal::instance(), + AWPluginMatcherSwapUsed::instance(), + AWPluginMatcherTime::instance(), + AWPluginMatcherUpgrade::instance(), + AWPluginMatcherUptime::instance(), + AWPluginMatcherVolume::instance(), + AWPluginMatcherWeather::instance(), +}; +}; diff --git a/sources/awesomewidgets/extitemaggregator.h b/sources/awesomewidgets/extitemaggregator.h index d315171..04da7d2 100644 --- a/sources/awesomewidgets/extitemaggregator.h +++ b/sources/awesomewidgets/extitemaggregator.h @@ -85,7 +85,7 @@ public: auto found = std::find_if(m_items.cbegin(), m_items.cend(), [&_tag, &_type](auto item) { return item->tag(_type) == _tag; }); - if (found == std::end(m_items)) { + if (found == m_items.cend()) { qCWarning(LOG_LIB) << "Could not find item by tag" << _tag; return nullptr; } @@ -99,7 +99,7 @@ public: auto found = std::find_if(m_items.cbegin(), m_items.cend(), [_number](auto item) { return item->number() == _number; }); - if (found == std::end(m_items)) { + if (found == m_items.cend()) { qCWarning(LOG_LIB) << "Could not find item by number" << _number; return nullptr; } diff --git a/sources/extsysmonsources/abstractextsysmonsource.h b/sources/extsysmonsources/abstractextsysmonsource.h index 69895f6..7d9fa49 100644 --- a/sources/extsysmonsources/abstractextsysmonsource.h +++ b/sources/extsysmonsources/abstractextsysmonsource.h @@ -46,8 +46,8 @@ public: return item ? item->run() : QVariantHash(); } static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type, - KSysGuard::Unit _unit = KSysGuard::UnitNone, - double _min = 0, double _max = 0); + KSysGuard::Unit _unit = KSysGuard::UnitNone, double _min = 0, + double _max = 0); signals: void dataReceived(const QVariantHash &);