mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
try again fix of initialization
This commit is contained in:
parent
608908fd02
commit
bab9f58b35
2
PKGBUILD
2
PKGBUILD
@ -21,7 +21,7 @@ optdepends=("amarok: for music player monitor"
|
|||||||
makedepends=('automoc4' 'cmake')
|
makedepends=('automoc4' 'cmake')
|
||||||
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||||
install=${pkgname}.install
|
install=${pkgname}.install
|
||||||
md5sums=('8d5f8a34da85927d094153ba6d09be84')
|
md5sums=('f6c726efd96a503fd5e5f3645998a49a')
|
||||||
backup=('usr/share/config/extsysmon.conf')
|
backup=('usr/share/config/extsysmon.conf')
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
|
||||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||||
@ -44,7 +45,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
|||||||
setMinimumPollingInterval(333);
|
setMinimumPollingInterval(333);
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
setProcesses();
|
setProcesses();
|
||||||
initValues();
|
setKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,9 +107,10 @@ QStringList ExtendedSysMon::sources() const
|
|||||||
|
|
||||||
void ExtendedSysMon::initValues()
|
void ExtendedSysMon::initValues()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[initValues]";
|
||||||
QStringList sourceList = sources();
|
QStringList sourceList = sources();
|
||||||
for (int i=0; i<sourceList.count(); i++)
|
for (int i=0; i<sourceList.count(); i++)
|
||||||
updateSourceEvent(sourceList[i]);
|
sourceRequestEvent(sourceList[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -155,6 +157,61 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::setKeys()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setKeys]";
|
||||||
|
QString key, source;
|
||||||
|
// custom
|
||||||
|
source = QString("custom");
|
||||||
|
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
key = QString("custom") + QString::number(i);
|
||||||
|
setData(source, key, QString(""));
|
||||||
|
}
|
||||||
|
// gpu
|
||||||
|
source = QString("gpu");
|
||||||
|
key = QString("GPU");
|
||||||
|
setData(source, key, float(0.0));
|
||||||
|
// gputemp
|
||||||
|
source = QString("gputemp");
|
||||||
|
key = QString("GPUTemp");
|
||||||
|
setData(source, key, float(0.0));
|
||||||
|
// hddtemp
|
||||||
|
source = QString("hddtemp");
|
||||||
|
for (int i=0; i<configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
key = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts)[i];
|
||||||
|
setData(source, key, float(0.0));
|
||||||
|
}
|
||||||
|
// pkg
|
||||||
|
source = QString("pkg");
|
||||||
|
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
key = QString("pkgCount") + QString::number(i);
|
||||||
|
setData(source, key, 0);
|
||||||
|
}
|
||||||
|
// player
|
||||||
|
source = QString("player");
|
||||||
|
key = QString("album");
|
||||||
|
setData(source, key, QString("unknown"));
|
||||||
|
key = QString("artist");
|
||||||
|
setData(source, key, QString("unknown"));
|
||||||
|
key = QString("duration");
|
||||||
|
setData(source, key, QString("0"));
|
||||||
|
key = QString("progress");
|
||||||
|
setData(source, key, QString("0"));
|
||||||
|
key = QString("title");
|
||||||
|
setData(source, key, QString("unknown"));
|
||||||
|
// ps
|
||||||
|
source = QString("ps");
|
||||||
|
key = QString("psCount");
|
||||||
|
setData(source, key, QString("0"));
|
||||||
|
key = QString("ps");
|
||||||
|
setData(source, key, QString(""));
|
||||||
|
key = QString("psTotal");
|
||||||
|
setData(source, key, QString("0"));
|
||||||
|
// initialization of values
|
||||||
|
initValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::setProcesses()
|
void ExtendedSysMon::setProcesses()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[setProcesses]";
|
if (debug) qDebug() << "[DE]" << "[setProcesses]";
|
||||||
@ -266,6 +323,8 @@ void ExtendedSysMon::getCustomCmd(const QString cmd, const int number)
|
|||||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
||||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with number" << number;
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with number" << number;
|
||||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << 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("\""));
|
processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +361,8 @@ void ExtendedSysMon::getGpu(const QString device)
|
|||||||
else if (device == QString("ati"))
|
else if (device == QString("ati"))
|
||||||
cmd = QString("aticonfig --od-getclocks");
|
cmd = QString("aticonfig --od-getclocks");
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||||
|
if ((processes[QString("gpu")][0]->state() != QProcess::Running) &&
|
||||||
|
(processes[QString("gpu")][0]->state() != QProcess::Starting))
|
||||||
processes[QString("gpu")][0]->start(cmd);
|
processes[QString("gpu")][0]->start(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,6 +416,8 @@ void ExtendedSysMon::getGpuTemp(const QString device)
|
|||||||
else if (device == QString("ati"))
|
else if (device == QString("ati"))
|
||||||
cmd = QString("aticonfig --od-gettemperature");
|
cmd = QString("aticonfig --od-gettemperature");
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||||
|
if ((processes[QString("gputemp")][0]->state() != QProcess::Running) &&
|
||||||
|
(processes[QString("gputemp")][0]->state() != QProcess::Running))
|
||||||
processes[QString("gputemp")][0]->start(cmd);
|
processes[QString("gputemp")][0]->start(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,6 +464,8 @@ 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 device" << device;
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with number" << number;
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with number" << number;
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << 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);
|
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" <<
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" <<
|
||||||
mpdAddress + QString(":") + mpdPort;
|
mpdAddress + QString(":") + mpdPort;
|
||||||
QString cmd;
|
QString cmd;
|
||||||
if (playerName == QString("amarok")) {
|
if (playerName == QString("amarok"))
|
||||||
// amarok
|
// amarok
|
||||||
cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\"");
|
cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
else if (playerName == QString("clementine"))
|
||||||
processes[QString("player")][0]->start(cmd);
|
|
||||||
}
|
|
||||||
else if (playerName == QString("clementine")) {
|
|
||||||
// clementine
|
// clementine
|
||||||
cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\"");
|
cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
else if (playerName == QString("mpd"))
|
||||||
processes[QString("player")][0]->start(cmd);
|
|
||||||
}
|
|
||||||
else if (playerName == QString("mpd")) {
|
|
||||||
// mpd
|
// mpd
|
||||||
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") +
|
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") +
|
||||||
mpdAddress + QString(":") + mpdPort + QString("\"");
|
mpdAddress + QString(":") + mpdPort + QString("\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
else if (playerName == QString("qmmp"))
|
||||||
processes[QString("player")][0]->start(cmd);
|
|
||||||
}
|
|
||||||
else if (playerName == QString("qmmp")) {
|
|
||||||
// qmmp
|
// qmmp
|
||||||
cmd = QString("bash -c \"pgrep qmmp && qmmp --status || echo 'null'\"");
|
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);
|
processes[QString("player")][0]->start(cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -590,9 +647,13 @@ void ExtendedSysMon::getPsStats()
|
|||||||
QString cmd;
|
QString cmd;
|
||||||
cmd = QString("ps --no-headers -o command");
|
cmd = QString("ps --no-headers -o command");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||||
|
if ((processes[QString("ps")][0]->state() != QProcess::Running) &&
|
||||||
|
(processes[QString("ps")][0]->state() != QProcess::Starting))
|
||||||
processes[QString("ps")][0]->start(cmd);
|
processes[QString("ps")][0]->start(cmd);
|
||||||
cmd = QString("ps -e --no-headers -o command");
|
cmd = QString("ps -e --no-headers -o command");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||||
|
if ((processes[QString("ps")][1]->state() != QProcess::Running) &&
|
||||||
|
(processes[QString("ps")][1]->state() != QProcess::Starting))
|
||||||
processes[QString("ps")][1]->start(cmd);
|
processes[QString("ps")][1]->start(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,6 +700,8 @@ void ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int number)
|
|||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number" << number;
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number" << number;
|
||||||
QString cmd = QString("bash -c \"") + pkgCommand + QString(" | wc -l\"");
|
QString cmd = QString("bash -c \"") + pkgCommand + QString(" | wc -l\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
if ((processes[QString("pkg")][number]->state() != QProcess::Running) &&
|
||||||
|
(processes[QString("pkg")][number]->state() != QProcess::Starting))
|
||||||
processes[QString("pkg")][number]->start(cmd);
|
processes[QString("pkg")][number]->start(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
QString getAutoGpu();
|
QString getAutoGpu();
|
||||||
void initValues();
|
void initValues();
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
|
void setKeys();
|
||||||
void setProcesses();
|
void setProcesses();
|
||||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user