From bab9f58b3534a12a76d687b93ce9ce9f9678d0ab Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 10 Jun 2014 10:42:15 +0400 Subject: [PATCH] try again fix of initialization --- PKGBUILD | 2 +- sources/ext-sysmon/extsysmon.cpp | 111 ++++++++++++++++++++++++------- sources/ext-sysmon/extsysmon.h | 1 + 3 files changed, 89 insertions(+), 25 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 900909b..7c5de00 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -21,7 +21,7 @@ optdepends=("amarok: for music player monitor" makedepends=('automoc4' 'cmake') source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz) install=${pkgname}.install -md5sums=('8d5f8a34da85927d094153ba6d09be84') +md5sums=('f6c726efd96a503fd5e5f3645998a49a') backup=('usr/share/config/extsysmon.conf') prepare() { diff --git a/sources/ext-sysmon/extsysmon.cpp b/sources/ext-sysmon/extsysmon.cpp index 3560073..612f3b4 100644 --- a/sources/ext-sysmon/extsysmon.cpp +++ b/sources/ext-sysmon/extsysmon.cpp @@ -26,6 +26,7 @@ #include #include #include +#include ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args) @@ -44,7 +45,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args) setMinimumPollingInterval(333); readConfiguration(); setProcesses(); - initValues(); + setKeys(); } @@ -106,9 +107,10 @@ QStringList ExtendedSysMon::sources() const void ExtendedSysMon::initValues() { + if (debug) qDebug() << "[DE]" << "[initValues]"; QStringList sourceList = sources(); for (int i=0; istart(QString("bash -c \"") + cmd + QString("\"")); + if ((processes[QString("custom")][number]->state() != QProcess::Running) && + (processes[QString("custom")][number]->state() != QProcess::Starting)) + processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\"")); } @@ -302,7 +361,9 @@ void ExtendedSysMon::getGpu(const QString device) else if (device == QString("ati")) cmd = QString("aticonfig --od-getclocks"); if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd; - processes[QString("gpu")][0]->start(cmd); + if ((processes[QString("gpu")][0]->state() != QProcess::Running) && + (processes[QString("gpu")][0]->state() != QProcess::Starting)) + processes[QString("gpu")][0]->start(cmd); } @@ -355,7 +416,9 @@ void ExtendedSysMon::getGpuTemp(const QString device) else if (device == QString("ati")) cmd = QString("aticonfig --od-gettemperature"); if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd; - processes[QString("gputemp")][0]->start(cmd); + if ((processes[QString("gputemp")][0]->state() != QProcess::Running) && + (processes[QString("gputemp")][0]->state() != QProcess::Running)) + processes[QString("gputemp")][0]->start(cmd); } @@ -401,7 +464,9 @@ void ExtendedSysMon::getHddTemp(const QString cmd, const QString device, const i if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device; if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with number" << number; if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device; - processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device); + if ((processes[QString("hddtemp")][number]->state() != QProcess::Running) && + (processes[QString("hddtemp")][number]->state() != QProcess::Starting)) + processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device); } @@ -438,31 +503,23 @@ void ExtendedSysMon::getPlayerInfo(const QString playerName, if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" << mpdAddress + QString(":") + mpdPort; QString cmd; - if (playerName == QString("amarok")) { + if (playerName == QString("amarok")) // amarok cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\""); - if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd; - processes[QString("player")][0]->start(cmd); - } - else if (playerName == QString("clementine")) { + else if (playerName == QString("clementine")) // clementine cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\""); - if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd; - processes[QString("player")][0]->start(cmd); - } - else if (playerName == QString("mpd")) { + else if (playerName == QString("mpd")) // mpd cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") + mpdAddress + QString(":") + mpdPort + QString("\""); - if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd; - processes[QString("player")][0]->start(cmd); - } - else if (playerName == QString("qmmp")) { + else if (playerName == QString("qmmp")) // qmmp cmd = QString("bash -c \"pgrep qmmp && qmmp --status || echo 'null'\""); - if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd; + if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd; + if ((processes[QString("player")][0]->state() != QProcess::Running) && + (processes[QString("player")][0]->state() != QProcess::Starting)) processes[QString("player")][0]->start(cmd); - } } @@ -590,10 +647,14 @@ void ExtendedSysMon::getPsStats() QString cmd; cmd = QString("ps --no-headers -o command"); if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd; - processes[QString("ps")][0]->start(cmd); + if ((processes[QString("ps")][0]->state() != QProcess::Running) && + (processes[QString("ps")][0]->state() != QProcess::Starting)) + processes[QString("ps")][0]->start(cmd); cmd = QString("ps -e --no-headers -o command"); if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd; - processes[QString("ps")][1]->start(cmd); + if ((processes[QString("ps")][1]->state() != QProcess::Running) && + (processes[QString("ps")][1]->state() != QProcess::Starting)) + processes[QString("ps")][1]->start(cmd); } @@ -639,7 +700,9 @@ void ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int number) if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number" << number; QString cmd = QString("bash -c \"") + pkgCommand + QString(" | wc -l\""); if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd; - processes[QString("pkg")][number]->start(cmd); + if ((processes[QString("pkg")][number]->state() != QProcess::Running) && + (processes[QString("pkg")][number]->state() != QProcess::Starting)) + processes[QString("pkg")][number]->start(cmd); } diff --git a/sources/ext-sysmon/extsysmon.h b/sources/ext-sysmon/extsysmon.h index 0f497b5..ccf8f4f 100644 --- a/sources/ext-sysmon/extsysmon.h +++ b/sources/ext-sysmon/extsysmon.h @@ -66,6 +66,7 @@ private: QString getAutoGpu(); void initValues(); void readConfiguration(); + void setKeys(); void setProcesses(); QMap updateConfiguration(const QMap rawConfig); };