diff --git a/sources/awesome-widget/deinteraction.cpp b/sources/awesome-widget/deinteraction.cpp index 6372578..ef4ec60 100644 --- a/sources/awesome-widget/deinteraction.cpp +++ b/sources/awesome-widget/deinteraction.cpp @@ -173,4 +173,101 @@ void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEng void AwesomeWidget::disconnectFromEngine() { if (debug) qDebug() << PDEBUG; + QRegExp regExp; + + // cpu + regExp = QRegExp(QString("cpu.*")); + if (foundKeys.indexOf(regExp) > -1) { + sysmonEngine->disconnectSource(QString("cpu/system/TotalLoad"), this); + int numCpus = getNumberCpus(); + for (int i=0; idisconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"), this); + } + // cpuclock + regExp = QRegExp(QString("cpucl.*")); + if (foundKeys.indexOf(regExp) > -1) { + sysmonEngine->disconnectSource(QString("cpu/system/AverageClock"), this); + int numCpus = getNumberCpus(); + for (int i=0; idisconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"), this); + } + // custom command + regExp = QRegExp(QString("custom.*")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("custom"), this); + // desktop + regExp = QRegExp(QString(".*desktop.*")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("desktop"), this); + // disk speed + regExp = QRegExp(QString("hdd[rw].*")); + if (foundKeys.indexOf(regExp) > -1) + for (int i=0; idisconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"), this); + sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"), this); + } + // gpu + regExp = QRegExp(QString("gpu")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("gpu"), this); + // gputemp + regExp = QRegExp(QString("gputemp")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("gputemp"), this); + // mount + regExp = QRegExp(QString("hdd([0-9]|mb|gb|totmb|totgb).*")); + if (foundKeys.indexOf(regExp) > -1) + for (int i=0; idisconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"), this); + sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"), this); + sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"), this); + } + // hddtemp + regExp = QRegExp(QString("hddtemp.*")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("hddtemp"), this); + // memory + regExp = QRegExp(QString("mem.*")); + if (foundKeys.indexOf(regExp) > -1) { + sysmonEngine->disconnectSource(QString("mem/physical/free"), this); + sysmonEngine->disconnectSource(QString("mem/physical/used"), this); + sysmonEngine->disconnectSource(QString("mem/physical/application"), this); + } + // network + regExp = QRegExp(QString("(down|up|netdev)")); + if (foundKeys.indexOf(regExp) > -1) { + sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this); + sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this); + } + // package manager + regExp = QRegExp(QString("pkgcount.*")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("pkg"), this); + // player + regExp = QRegExp(QString("(album|artist|duration|progress|title)")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("player"), this); + // ps + regExp = QRegExp(QString("ps.*")); + if (foundKeys.indexOf(regExp) > -1) + extsysmonEngine->disconnectSource(QString("ps"), this); + // swap + regExp = QRegExp(QString("swap.*")); + if (foundKeys.indexOf(regExp) > -1) { + sysmonEngine->disconnectSource(QString("mem/swap/free"), this); + sysmonEngine->disconnectSource(QString("mem/swap/used"), this); + } + // temp + regExp = QRegExp(QString("temp.*")); + if (foundKeys.indexOf(regExp) > -1) + for (int i=0; idisconnectSource(configuration[QString("tempDevice")].split(QString("@@"))[i], this); + // time + regExp = QRegExp(QString("(^|iso|short|long|c)time")); + if (foundKeys.indexOf(regExp) > -1) + timeEngine->disconnectSource(QString("Local"), this); + // uptime + regExp = QRegExp(QString("(^|c)uptime")); + if (foundKeys.indexOf(regExp) > -1) + sysmonEngine->disconnectSource(QString("system/uptime"), this); } diff --git a/sources/ext-sysmon/extsysmon.conf b/sources/ext-sysmon/extsysmon.conf index d2d1cb7..9f107ad 100644 --- a/sources/ext-sysmon/extsysmon.conf +++ b/sources/ext-sysmon/extsysmon.conf @@ -1,6 +1,10 @@ # Configuration file for Extended Systemmonitor DataEngine # $kdehome/share/config/extsysmon.conf +# ACPI devices +#AC=/sys/class/power_supply/AC/online +#BATTERY=/sys/class/power_supply/BAT0/capacity + # Custom command, separator is '@@' #CUSTOM=curl ip4.telize.com diff --git a/sources/ext-sysmon/extsysmon.cpp b/sources/ext-sysmon/extsysmon.cpp index db0082c..bfb6b6d 100644 --- a/sources/ext-sysmon/extsysmon.cpp +++ b/sources/ext-sysmon/extsysmon.cpp @@ -150,6 +150,7 @@ QStringList ExtendedSysMon::sources() const if (debug) qDebug() << PDEBUG; QStringList source; + source.append(QString("battery")); source.append(QString("custom")); source.append(QString("desktop")); source.append(QString("gpu")); @@ -170,6 +171,8 @@ void ExtendedSysMon::readConfiguration() // pre-setup QMap rawConfig; + rawConfig[QString("AC")] = QString("/sys/class/power_supply/AC/online"); + rawConfig[QString("BATTERY")] = QString("/sys/class/power_supply/BAT0/capacity"); rawConfig[QString("CUSTOM")] = QString("curl ip4.telize.com"); rawConfig[QString("DESKTOP")] = QString(""); rawConfig[QString("DESKTOPCMD")] = QString("qdbus org.kde.kwin /KWin currentDesktop"); @@ -275,6 +278,28 @@ QMap ExtendedSysMon::updateConfiguration(const QMap ExtendedSysMon::getBattery(const QString acPath, const QString batPath) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "AC path" << acPath; + if (debug) qDebug() << PDEBUG << ":" << "Battery path" << batPath; + + QMap battery; + battery[QString("ac")] = 0; + battery[QString("battery")] = 0; + QFile acFile(acPath); + if (acFile.open(QIODevice::ReadOnly)) + battery[QString("ac")] = QString(acFile.readLine()).trimmed().toInt(); + acFile.close(); + QFile batFile(batPath); + if (batFile.open(QIODevice::ReadOnly)) + battery[QString("battery")] = QString(batFile.readLine()).trimmed().toInt(); + batFile.close(); + + return battery; +} + + QMap ExtendedSysMon::getCurrentDesktop(const QString cmd) { if (debug) qDebug() << PDEBUG; @@ -543,7 +568,12 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Source" << source; - if (source == QString("custom")) { + if (source == QString("battery")) { + QMap battery = getBattery(configuration[QString("AC")], + configuration[QString("BATTERY")]); + setData(source, QString("ac"), QString::number(battery[QString("ac")])); + setData(source, QString("bat"), QString::number(battery[QString("battery")])); + } else if (source == QString("custom")) { for (int i=0; i getBattery(const QString acPath, const QString batPath); QMap getCurrentDesktop(const QString cmd); QString getCustomCmd(const QString cmd); float getGpu(const QString device);