mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
gpu support
This commit is contained in:
@ -170,9 +170,6 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration()
|
||||
|
||||
settings.beginGroup("Configuration");
|
||||
configuration["ACPIPATH"] = settings.value("ACPIPATH", "/sys/class/power_supply/");
|
||||
configuration["GPUDEV"] = settings.value("GPUDEV", "auto");
|
||||
configuration["HDDDEV"] = settings.value("HDDDEV", "all");
|
||||
configuration["HDDTEMPCMD"] = settings.value("HDDTEMPCMD", "sudo smartctl -a");
|
||||
configuration["MPDADDRESS"] = settings.value("MPDADDRESS", "localhost");
|
||||
configuration["MPDPORT"] = settings.value("MPDPORT", "6600");
|
||||
configuration["MPRIS"] = settings.value("MPRIS", "auto");
|
||||
@ -197,9 +194,6 @@ bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configurat
|
||||
|
||||
settings.beginGroup("Configuration");
|
||||
settings.setValue("ACPIPATH", _configuration["ACPIPATH"]);
|
||||
settings.setValue("GPUDEV", _configuration["GPUDEV"]);
|
||||
settings.setValue("HDDDEV", _configuration["HDDDEV"]);
|
||||
settings.setValue("HDDTEMPCMD", _configuration["HDDTEMPCMD"]);
|
||||
settings.setValue("MPDADDRESS", _configuration["MPDADDRESS"]);
|
||||
settings.setValue("MPDPORT", _configuration["MPDPORT"]);
|
||||
settings.setValue("MPRIS", _configuration["MPRIS"]);
|
||||
|
@ -89,6 +89,9 @@ void AWDataEngineAggregator::loadSources()
|
||||
auto sensors = response.value();
|
||||
updateSensors(sensors);
|
||||
connectSources();
|
||||
|
||||
for (auto &sensor : m_sensors.keys())
|
||||
emit(deviceAdded(sensor));
|
||||
}
|
||||
|
||||
|
||||
@ -121,6 +124,9 @@ void AWDataEngineAggregator::sensorAdded(const QString &_sensor)
|
||||
m_interface->subscribe({_sensor}).waitForFinished();
|
||||
m_subscribed.insert(_sensor);
|
||||
}
|
||||
|
||||
// notify about new device
|
||||
emit(deviceAdded(_sensor));
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +85,8 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
|
||||
auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
|
||||
auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
|
||||
auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
|
||||
auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$");
|
||||
auto hddrRegExp = QRegularExpression("^disk/.*/read$");
|
||||
auto hddwRegExp = QRegularExpression("^disk/.*/write$");
|
||||
auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
|
||||
@ -99,7 +101,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["ac"] = AWKeysAggregator::FormatterType::ACFormat;
|
||||
} else if (_source.startsWith("extsysmon/battery/")) {
|
||||
// battery stats
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/battery/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float
|
||||
@ -110,7 +112,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source.contains(cpuRegExp)) {
|
||||
// cpus
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("cpu/").remove("/usage");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
||||
@ -120,14 +122,14 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer;
|
||||
} else if (_source.contains(cpuclRegExp)) {
|
||||
// cpucls
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("cpu/cpu").remove("/frequency");
|
||||
key = QString("cpucl%1").arg(key);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
||||
} else if (_source.startsWith("extsysmon/custom")) {
|
||||
// custom
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/custom/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
@ -145,9 +147,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["tdesktops"] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.contains(hddrRegExp)) {
|
||||
// read speed
|
||||
QString device = _source;
|
||||
auto device = _source;
|
||||
device.remove("disk/").remove("/read");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
auto index = m_devices["disk"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddr%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
@ -155,29 +157,45 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
}
|
||||
} else if (_source.contains(hddwRegExp)) {
|
||||
// write speed
|
||||
QString device = _source;
|
||||
auto device = _source;
|
||||
device.remove("disk/").remove("/write");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
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] = AWKeysAggregator::FormatterType::Integer;
|
||||
}
|
||||
} else if (_source == "extsysmon/gpuload/load") {
|
||||
} else if (_source == "gpu/all/usage") {
|
||||
// gpu load
|
||||
m_map.insert(_source, "gpu");
|
||||
m_formatter["gpu"] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source == "extsysmon/gputemp/temperature") {
|
||||
// gpu temperature
|
||||
m_map.insert(_source, "gputemp");
|
||||
m_formatter["gputemp"] = AWKeysAggregator::FormatterType::Temperature;
|
||||
} 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] = AWKeysAggregator::FormatterType::Float;
|
||||
}
|
||||
} 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] = AWKeysAggregator::FormatterType::Temperature;
|
||||
}
|
||||
} else if (_source.contains(mountFillRegExp)) {
|
||||
// fill level
|
||||
QString device = _source;
|
||||
auto device = _source;
|
||||
device.remove("disk/").remove("/usedPercent");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
auto index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hdd%1").arg(index);
|
||||
auto key = QString("hdd%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
||||
// additional keys
|
||||
@ -186,9 +204,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
}
|
||||
} else if (_source.contains(mountFreeRegExp)) {
|
||||
// free space
|
||||
QString device = _source;
|
||||
auto device = _source;
|
||||
device.remove("disk/").remove("/free");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
auto index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
QString key = QString("hddfreemb%1").arg(index);
|
||||
@ -201,9 +219,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
}
|
||||
} else if (_source.contains(mountUsedRegExp)) {
|
||||
// used
|
||||
QString device = _source;
|
||||
auto device = _source;
|
||||
device.remove("disk/").remove("/used");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
auto index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
QString key = QString("hddmb%1").arg(index);
|
||||
@ -214,21 +232,11 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
}
|
||||
} else if (_source.startsWith("extsysmon/hdd/temperature")) {
|
||||
// hdd temperature
|
||||
QString device = _source;
|
||||
device.remove("extsysmon/hdd/temperature");
|
||||
int index = m_devices["hdd"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddtemp%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
}
|
||||
} else if (_source.startsWith("cpu/loadaverages/loadaverage")) {
|
||||
// load average
|
||||
QString time = _source;
|
||||
auto time = _source;
|
||||
time.remove("cpu/loadaverages/loadaverage");
|
||||
QString key = QString("la%1").arg(time);
|
||||
auto key = QString("la%1").arg(time);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols;
|
||||
} else if (_source == "memory/physical/application") {
|
||||
@ -265,17 +273,17 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.startsWith("extsysmon/requests/response")) {
|
||||
// network response
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/requests/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.contains(netRegExp)) {
|
||||
// network speed
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
auto type = _source.endsWith("download") ? "down" : "up";
|
||||
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
QString key = QString("%1kb%2").arg(type).arg(index);
|
||||
auto key = QString("%1kb%2").arg(type).arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
||||
// smart
|
||||
@ -289,11 +297,11 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
}
|
||||
} else if (_source.contains(netTotalRegExp)) {
|
||||
// network data total
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
auto type = _source.endsWith("Download") ? "down" : "up";
|
||||
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
QString key = QString("%1totkb%2").arg(type).arg(index);
|
||||
auto key = QString("%1totkb%2").arg(type).arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
||||
// mb
|
||||
@ -303,13 +311,13 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
}
|
||||
} else if (_source.startsWith("extsysmon/upgrade")) {
|
||||
// package manager
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/upgrade/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree;
|
||||
} else if (_source.startsWith("extsysmon/player")) {
|
||||
// player
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/player/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
@ -327,7 +335,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["pstot"] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.startsWith("extsysmon/quotes")) {
|
||||
// quotes
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/quotes/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Quotes;
|
||||
@ -355,7 +363,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
if (_units == KSysGuard::UnitInvalid)
|
||||
return QStringList({QString("temp%1").arg(index)});
|
||||
if (index > -1) {
|
||||
QString key = QString("temp%1").arg(index);
|
||||
auto key = QString("temp%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
@ -394,19 +402,19 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
|
||||
m_formatter["cuptime"] = AWKeysAggregator::FormatterType::UptimeCustom;
|
||||
} else if (_source.startsWith("extsysmon/weather/temperature")) {
|
||||
// temperature
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/weather/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
} else if (_source.startsWith("extsysmon/weather/")) {
|
||||
// other weather
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/weather/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.startsWith("extsysmon/load/load")) {
|
||||
// load source
|
||||
QString key = _source;
|
||||
auto key = _source;
|
||||
key.remove("extsysmon/load/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
|
@ -31,7 +31,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << _key << "with type" << _type;
|
||||
|
||||
QString fileName
|
||||
auto fileName
|
||||
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
@ -41,19 +41,8 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
|
||||
for (auto &number : cache.allKeys())
|
||||
cachedValues.append(cache.value(number).toString());
|
||||
|
||||
if (_type == "hdd") {
|
||||
QStringList allDevices = QDir("/dev").entryList(QDir::System, QDir::Name);
|
||||
QStringList devices = allDevices.filter(QRegularExpression("^[hms]d[a-z]$"));
|
||||
for (auto &dev : devices) {
|
||||
QString device = QString("/dev/%1").arg(dev);
|
||||
if (cachedValues.contains(device))
|
||||
continue;
|
||||
qCInfo(LOG_AW) << "Found new key" << device << "for type" << _type;
|
||||
cachedValues.append(device);
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||
}
|
||||
} else if (_type == "net") {
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
if (_type == "net") {
|
||||
auto rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (auto &interface : rawInterfaceList) {
|
||||
QString device = interface.name();
|
||||
if (cachedValues.contains(device))
|
||||
@ -98,7 +87,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
key.remove("hddtotmb");
|
||||
int index = key.toInt();
|
||||
auto index = key.toInt();
|
||||
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
|
||||
}
|
||||
// hddtotgb*
|
||||
@ -106,7 +95,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
key.remove("hddtotgb");
|
||||
int index = key.toInt();
|
||||
auto index = key.toInt();
|
||||
used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index);
|
||||
}
|
||||
// mem
|
||||
@ -139,7 +128,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
||||
for (auto &key : netKeys) {
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
QStringList filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
|
||||
auto filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
|
||||
for (auto &filtered : filt)
|
||||
used << filtered;
|
||||
}
|
||||
@ -158,7 +147,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
||||
|
||||
QHash<QString, QStringList> AWKeyCache::loadKeysFromCache()
|
||||
{
|
||||
QString fileName
|
||||
auto fileName
|
||||
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
|
@ -72,7 +72,6 @@ QHash<QString, QStringList> AWKeyOperations::devices() const
|
||||
void AWKeyOperations::updateCache()
|
||||
{
|
||||
// update network and hdd list
|
||||
addKeyToCache("hdd");
|
||||
addKeyToCache("net");
|
||||
}
|
||||
|
||||
@ -90,15 +89,20 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
allKeys.append(item->tag("timestamp"));
|
||||
}
|
||||
// cpuclock & cpu
|
||||
for (int i = 0; i < QThread::idealThreadCount(); i++) {
|
||||
for (auto i = 0; i < QThread::idealThreadCount(); i++) {
|
||||
allKeys.append(QString("cpucl%1").arg(i));
|
||||
allKeys.append(QString("cpu%1").arg(i));
|
||||
}
|
||||
// temperature
|
||||
for (int i = 0; i < m_devices["temp"].count(); i++)
|
||||
for (auto i = 0; i < m_devices["temp"].count(); i++)
|
||||
allKeys.append(QString("temp%1").arg(i));
|
||||
// gpu
|
||||
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 (int 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));
|
||||
@ -108,15 +112,12 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
allKeys.append(QString("hdd%1").arg(i));
|
||||
}
|
||||
// hdd speed
|
||||
for (int 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));
|
||||
}
|
||||
// hdd temp
|
||||
for (int i = 0; i < m_devices["hdd"].count(); i++)
|
||||
allKeys.append(QString("hddtemp%1").arg(i));
|
||||
// network
|
||||
for (int i = 0; i < m_devices["net"].count(); i++) {
|
||||
for (auto i = 0; i < m_devices["net"].count(); i++) {
|
||||
allKeys.append(QString("downunits%1").arg(i));
|
||||
allKeys.append(QString("upunits%1").arg(i));
|
||||
allKeys.append(QString("downtotkb%1").arg(i));
|
||||
@ -129,7 +130,7 @@ QStringList AWKeyOperations::dictKeys() const
|
||||
allKeys.append(QString("up%1").arg(i));
|
||||
}
|
||||
// battery
|
||||
QStringList allBatteryDevices
|
||||
auto allBatteryDevices
|
||||
= QDir("/sys/class/power_supply")
|
||||
.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
for (int i = 0; i < allBatteryDevices.count(); i++) {
|
||||
@ -205,52 +206,48 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Requested key" << _key;
|
||||
|
||||
QString stripped = _key;
|
||||
auto stripped = _key;
|
||||
stripped.remove(QRegularExpression("\\d+"));
|
||||
QString output;
|
||||
|
||||
if (_key.startsWith("bar")) {
|
||||
AbstractExtItem *item = m_graphicalItems->itemByTag(_key, stripped);
|
||||
auto *item = m_graphicalItems->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (_key.startsWith("custom")) {
|
||||
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
|
||||
auto *item = m_extScripts->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
|
||||
QString index = _key;
|
||||
auto index = _key;
|
||||
index.remove(QRegularExpression("hdd[rw]"));
|
||||
output = m_devices["disk"][index.toInt()];
|
||||
} else if (_key.contains(QRegularExpression("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) {
|
||||
QString index = _key;
|
||||
auto index = _key;
|
||||
index.remove(QRegularExpression("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
|
||||
output = m_devices["mount"][index.toInt()];
|
||||
} else if (_key.startsWith("hddtemp")) {
|
||||
QString index = _key;
|
||||
index.remove("hddtemp");
|
||||
output = m_devices["hdd"][index.toInt()];
|
||||
} else if (_key.contains(QRegularExpression("^(down|up)[0-9]"))) {
|
||||
QString index = _key;
|
||||
auto index = _key;
|
||||
index.remove(QRegularExpression("^(down|up)"));
|
||||
output = m_devices["net"][index.toInt()];
|
||||
} else if (_key.startsWith("pkgcount")) {
|
||||
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
|
||||
auto *item = m_extUpgrade->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
|
||||
AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped);
|
||||
auto *item = m_extQuotes->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
|
||||
AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped);
|
||||
auto *item = m_extWeather->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else if (_key.startsWith("temp")) {
|
||||
QString index = _key;
|
||||
auto index = _key;
|
||||
index.remove("temp");
|
||||
output = m_devices["temp"][index.toInt()];
|
||||
} else if (_key.startsWith("response")) {
|
||||
AbstractExtItem *item = m_extNetRequest->itemByTag(_key, stripped);
|
||||
auto *item = m_extNetRequest->itemByTag(_key, stripped);
|
||||
if (item)
|
||||
output = item->uniq();
|
||||
} else {
|
||||
@ -302,9 +299,10 @@ void AWKeyOperations::addDevice(const QString &_source)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _source;
|
||||
|
||||
auto diskRegexp = QRegularExpression("disk/.*/read");
|
||||
auto mountRegexp = QRegularExpression("disk/.*/usedPercent");
|
||||
auto diskRegexp = QRegularExpression("^disk/.*/read$");
|
||||
auto mountRegexp = QRegularExpression("^disk/.*/usedPercent$");
|
||||
auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
|
||||
auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
|
||||
|
||||
if (_source.contains(diskRegexp)) {
|
||||
auto device = _source;
|
||||
@ -317,6 +315,10 @@ void AWKeyOperations::addDevice(const QString &_source)
|
||||
} else if (_source.startsWith("lmsensors") || _source.contains(cpuTempRegExp)
|
||||
|| _source == "cpu/all/averageTemperature") {
|
||||
addKeyToCache("temp", _source);
|
||||
} else if (_source.contains(gpuRegExp)) {
|
||||
auto device = _source;
|
||||
device.remove("gpu/").remove("/usage");
|
||||
addKeyToCache("gpu", device);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void AWKeys::initKeys(const QString &_currentPattern, const int _interval, const
|
||||
m_aggregator->initFormatters();
|
||||
m_keyOperator->setPattern(_currentPattern);
|
||||
m_keyOperator->updateCache();
|
||||
m_dataEngineAggregator->connectSources();
|
||||
m_dataEngineAggregator->loadSources();
|
||||
|
||||
// timer
|
||||
m_timer->setInterval(_interval);
|
||||
|
Reference in New Issue
Block a user