mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-08-20 15:49:55 +00:00
port widget to dbus
This commit is contained in:
@ -76,20 +76,20 @@ QStringList AWDataEngineMapper::keysFromSource(const QString &_source) const
|
||||
|
||||
// HACK units required to define should the value be calculated as temperature
|
||||
// or fan data
|
||||
QStringList AWDataEngineMapper::registerSource(const QString &_source, const QString &_units, const QStringList &_keys)
|
||||
QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
|
||||
|
||||
// regular expressions
|
||||
auto cpuRegExp = QRegularExpression("cpu/cpu.*/TotalLoad");
|
||||
auto cpuclRegExp = QRegularExpression("cpu/cpu.*/clock");
|
||||
auto hddrRegExp = QRegularExpression("disk/.*/Rate/rblk");
|
||||
auto hddwRegExp = QRegularExpression("disk/.*/Rate/wblk");
|
||||
auto mountFillRegExp = QRegularExpression("partitions/.*/filllevel");
|
||||
auto mountFreeRegExp = QRegularExpression("partitions/.*/freespace");
|
||||
auto mountUsedRegExp = QRegularExpression("partitions/.*/usedspace");
|
||||
auto netRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/data$");
|
||||
auto netTotalRegExp = QRegularExpression("network/interfaces/.*/(receiver|transmitter)/dataTotal$");
|
||||
auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
|
||||
auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
|
||||
auto hddrRegExp = QRegularExpression("^disk/.*/read$");
|
||||
auto hddwRegExp = QRegularExpression("^disk/.*/write$");
|
||||
auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
|
||||
auto mountFreeRegExp = QRegularExpression("^disk/.*/free$");
|
||||
auto mountUsedRegExp = QRegularExpression("^disk/.*/used$");
|
||||
auto netRegExp = QRegularExpression("^network/.*/(download|upload)$");
|
||||
auto netTotalRegExp = QRegularExpression("^network/.*/(totalDownload|totalUpload)$");
|
||||
|
||||
if (_source == "battery/ac") {
|
||||
// AC
|
||||
@ -102,24 +102,24 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float
|
||||
: AWKeysAggregator::FormatterType::IntegerThree;
|
||||
} else if (_source == "cpu/system/TotalLoad") {
|
||||
} else if (_source == "cpu/all/usage") {
|
||||
// cpu
|
||||
m_map.insert(_source, "cpu");
|
||||
m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source.contains(cpuRegExp)) {
|
||||
// cpus
|
||||
QString key = _source;
|
||||
key.remove("cpu/").remove("/TotalLoad");
|
||||
key.remove("cpu/").remove("/usage");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
|
||||
} else if (_source == "cpu/system/AverageClock") {
|
||||
} else if (_source == "cpu/all/averageFrequency") {
|
||||
// cpucl
|
||||
m_map.insert(_source, "cpucl");
|
||||
m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer;
|
||||
} else if (_source.contains(cpuclRegExp)) {
|
||||
// cpucls
|
||||
QString key = _source;
|
||||
key.remove("cpu/cpu").remove("/clock");
|
||||
key.remove("cpu/cpu").remove("/frequency");
|
||||
key = QString("cpucl%1").arg(key);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
|
||||
@ -144,7 +144,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(hddrRegExp)) {
|
||||
// read speed
|
||||
QString device = _source;
|
||||
device.remove("/Rate/rblk");
|
||||
device.remove("disk/").remove("/read");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddr%1").arg(index);
|
||||
@ -154,7 +154,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(hddwRegExp)) {
|
||||
// write speed
|
||||
QString device = _source;
|
||||
device.remove("/Rate/wblk");
|
||||
device.remove("disk/").remove("/write");
|
||||
int index = m_devices["disk"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hddw%1").arg(index);
|
||||
@ -172,7 +172,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountFillRegExp)) {
|
||||
// fill level
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/filllevel");
|
||||
device.remove("disk/").remove("/usedPercent");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
QString key = QString("hdd%1").arg(index);
|
||||
@ -185,7 +185,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountFreeRegExp)) {
|
||||
// free space
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/freespace");
|
||||
device.remove("disk/").remove("/free");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
@ -200,7 +200,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
} else if (_source.contains(mountUsedRegExp)) {
|
||||
// used
|
||||
QString device = _source;
|
||||
device.remove("partitions").remove("/usedspace");
|
||||
device.remove("disk/").remove("/used");
|
||||
int index = m_devices["mount"].indexOf(device);
|
||||
if (index > -1) {
|
||||
// mb
|
||||
@ -222,14 +222,14 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
|
||||
}
|
||||
} else if (_source.startsWith("cpu/system/loadavg")) {
|
||||
} else if (_source.startsWith("cpu/loadaverages/loadaverage")) {
|
||||
// load average
|
||||
QString time = _source;
|
||||
time.remove("cpu/system/loadavg");
|
||||
time.remove("cpu/loadaverages/loadaverage");
|
||||
QString key = QString("la%1").arg(time);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols;
|
||||
} else if (_source == "mem/physical/application") {
|
||||
} else if (_source == "memory/physical/application") {
|
||||
// app memory
|
||||
// mb
|
||||
m_map.insert(_source, "memmb");
|
||||
@ -237,7 +237,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "memgb");
|
||||
m_formatter["memgb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/physical/free") {
|
||||
} else if (_source == "memory/physical/free") {
|
||||
// free memory
|
||||
// mb
|
||||
m_map.insert(_source, "memfreemb");
|
||||
@ -245,7 +245,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "memfreegb");
|
||||
m_formatter["memfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/physical/used") {
|
||||
} else if (_source == "memory/physical/used") {
|
||||
// used memory
|
||||
// mb
|
||||
m_map.insert(_source, "memusedmb");
|
||||
@ -269,7 +269,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
|
||||
} else if (_source.contains(netRegExp)) {
|
||||
// network speed
|
||||
QString type = _source.contains("receiver") ? "down" : "up";
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
@ -287,7 +287,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
}
|
||||
} else if (_source.contains(netTotalRegExp)) {
|
||||
// network data total
|
||||
QString type = _source.contains("receiver") ? "down" : "up";
|
||||
QString type = _source.contains("download") ? "down" : "up";
|
||||
int index = m_devices["net"].indexOf(_source.split('/')[2]);
|
||||
if (index > -1) {
|
||||
// kb
|
||||
@ -329,7 +329,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
key.remove("quotes/");
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = AWKeysAggregator::FormatterType::Quotes;
|
||||
} else if (_source == "mem/swap/free") {
|
||||
} else if (_source == "memory/swap/free") {
|
||||
// free swap
|
||||
// mb
|
||||
m_map.insert(_source, "swapfreemb");
|
||||
@ -337,7 +337,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// gb
|
||||
m_map.insert(_source, "swapfreegb");
|
||||
m_formatter["swapfreegb"] = AWKeysAggregator::FormatterType::MemGBFormat;
|
||||
} else if (_source == "mem/swap/used") {
|
||||
} else if (_source == "memory/swap/used") {
|
||||
// used swap
|
||||
// mb
|
||||
m_map.insert(_source, "swapmb");
|
||||
@ -349,13 +349,13 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const QSt
|
||||
// temperature
|
||||
int index = m_devices["temp"].indexOf(_source);
|
||||
// HACK on DE initialization there are no units key
|
||||
if (_units.isEmpty())
|
||||
if (_units == KSysGuard::UnitInvalid)
|
||||
return QStringList({QString("temp%1").arg(index)});
|
||||
if (index > -1) {
|
||||
QString key = QString("temp%1").arg(index);
|
||||
m_map.insert(_source, key);
|
||||
m_formatter[key] = _units == "°C" ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
|
||||
: AWKeysAggregator::FormatterType::Integer;
|
||||
}
|
||||
} else if (_source == "Local") {
|
||||
// time
|
||||
|
Reference in New Issue
Block a user