mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
add support of multithreading to all functions of dataengine
This commit is contained in:
parent
64bc89ba75
commit
61e2a380b9
@ -143,17 +143,49 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
}
|
}
|
||||||
confFile.close();
|
confFile.close();
|
||||||
configuration = updateConfiguration(rawConfig);
|
configuration = updateConfiguration(rawConfig);
|
||||||
setCustomProcesses();
|
setProcesses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::setCustomProcesses()
|
void ExtendedSysMon::setProcesses()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[setCustomProcesses]";
|
if (debug) qDebug() << "[DE]" << "[setProcesses]";
|
||||||
|
// custom
|
||||||
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
||||||
customProcesses.append(new QProcess);
|
processes[QString("custom")].append(new QProcess);
|
||||||
connect(customProcesses[i], SIGNAL(readyReadStandardOutput()), this, SLOT(setCustomCmd()));
|
connect(processes[QString("custom")][i], SIGNAL(readyReadStandardOutput()), this, SLOT(setCustomCmd()));
|
||||||
}
|
}
|
||||||
|
// gpu
|
||||||
|
processes[QString("gpu")].append(new QProcess);
|
||||||
|
connect(processes[QString("gpu")][0], SIGNAL(readyReadStandardOutput()), this, SLOT(getGpu()));
|
||||||
|
// gputemp
|
||||||
|
processes[QString("gputemp")].append(new QProcess);
|
||||||
|
connect(processes[QString("gputemp")][0], SIGNAL(readyReadStandardOutput()), this, SLOT(getGpuTemp()));
|
||||||
|
// hddtemp
|
||||||
|
for (int i=0; i<configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
processes[QString("hddtemp")].append(new QProcess);
|
||||||
|
connect(processes[QString("hddtemp")][i], SIGNAL(readyReadStandardOutput()), this, SLOT(setHddTemp()));
|
||||||
|
}
|
||||||
|
// pkg
|
||||||
|
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
processes[QString("pkg")].append(new QProcess);
|
||||||
|
connect(processes[QString("pkg")][i], SIGNAL(readyReadStandardOutput()), this, SLOT(setPkg()));
|
||||||
|
}
|
||||||
|
// player
|
||||||
|
// two processes because amarok and clementine requires two commands
|
||||||
|
// general
|
||||||
|
processes[QString("player")].append(new QProcess);
|
||||||
|
connect(processes[QString("player")][0], SIGNAL(readyReadStandardOutput()), this, SLOT(setPlayer()));
|
||||||
|
// addition
|
||||||
|
processes[QString("player")].append(new QProcess);
|
||||||
|
connect(processes[QString("player")][1], SIGNAL(readyReadStandardOutput()), this, SLOT(setPlayer()));
|
||||||
|
// ps
|
||||||
|
// pscount && ps
|
||||||
|
processes[QString("ps")].append(new QProcess);
|
||||||
|
connect(processes[QString("ps")][0], SIGNAL(readyReadStandardOutput()), this, SLOT(setPs()));
|
||||||
|
// pstotal
|
||||||
|
processes[QString("ps")].append(new QProcess);
|
||||||
|
connect(processes[QString("ps")][2], SIGNAL(readyReadStandardOutput()), this, SLOT(setPs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,18 +254,18 @@ void ExtendedSysMon::getCustomCmd(const QString cmd, const int number)
|
|||||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]";
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]";
|
||||||
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 cmd" << QString("bash -c \"") + cmd + QString("\"");
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
||||||
customProcesses[number]->start(QString("bash -c \"") + cmd + QString("\""));
|
processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::setCustomCmd()
|
void ExtendedSysMon::setCustomCmd()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]";
|
if (debug) qDebug() << "[DE]" << "[setCustomCmd]";
|
||||||
for (int i=0; i<customProcesses.count(); i++) {
|
for (int i=0; i<processes[QString("custom")].count(); i++) {
|
||||||
QString value = QString("");
|
QString value = QString("");
|
||||||
value = QTextCodec::codecForMib(106)->toUnicode(customProcesses[i]->readAllStandardOutput()).trimmed();
|
value = QTextCodec::codecForMib(106)->toUnicode(processes[QString("custom")][i]->readAllStandardOutput()).trimmed();
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Found output for cmd" << i;
|
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Found data for cmd" << i;
|
||||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Return" << value;
|
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Return" << value;
|
||||||
QString source = QString("custom");
|
QString source = QString("custom");
|
||||||
QString key = QString("custom") + QString::number(i);
|
QString key = QString("custom") + QString::number(i);
|
||||||
@ -243,129 +275,192 @@ void ExtendedSysMon::setCustomCmd()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getGpu(const QString device)
|
void ExtendedSysMon::getGpu(const QString device)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]";
|
if (debug) qDebug() << "[DE]" << "[getGpu]";
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run function with device" << device;
|
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run function with device" << device;
|
||||||
float gpu = 0.0;
|
|
||||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||||
return gpu;
|
return;
|
||||||
QProcess command;
|
|
||||||
QString qoutput;
|
|
||||||
|
|
||||||
if (device == QString("nvidia")) {
|
if (device == QString("nvidia")) {
|
||||||
QString cmd = QString("nvidia-smi -q -d UTILIZATION");
|
QString cmd = QString("nvidia-smi -q -d UTILIZATION");
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||||
command.start(cmd);
|
processes[QString("gpu")][0]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
else if (device == QString("ati")) {
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
QString cmd = QString("aticonfig --od-getclocks");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("gpu")][0]->start(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::setGpu()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setGpu]";
|
||||||
|
float value = 0.0;
|
||||||
|
QString qoutput;
|
||||||
|
if (configuration[QString("GPUDEV")] == QString("nvidia")) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gpu")][0]->readAllStandardOutput());
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||||
.split(QChar(' '), QString::SkipEmptyParts)[2]
|
.split(QChar(' '), QString::SkipEmptyParts)[2]
|
||||||
.remove(QChar('%'));
|
.remove(QChar('%'));
|
||||||
gpu = load.toFloat();
|
value = load.toFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (device == QString("ati")) {
|
else if (configuration[QString("GPUDEV")] == QString("ati")) {
|
||||||
QString cmd = QString("aticonfig --od-getclocks");
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gpu")][0]->readAllStandardOutput());
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
|
||||||
command.start(cmd);
|
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
|
||||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||||
.split(QChar(' '), QString::SkipEmptyParts)[3]
|
.split(QChar(' '), QString::SkipEmptyParts)[3]
|
||||||
.remove(QChar('%'));
|
.remove(QChar('%'));
|
||||||
gpu = load.toFloat();
|
value = load.toFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Return" << gpu;
|
if (debug) qDebug() << "[DE]" << "[setGpu]" << ":" << "Return" << value;
|
||||||
return gpu;
|
QString source = QString("gpu");
|
||||||
|
QString key = QString("GPU");
|
||||||
|
setData(source, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getGpuTemp(const QString device)
|
void ExtendedSysMon::getGpuTemp(const QString device)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]";
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]";
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
||||||
float gpuTemp = 0.0;
|
|
||||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||||
return gpuTemp;
|
return;
|
||||||
QProcess command;
|
|
||||||
QString qoutput;
|
|
||||||
|
|
||||||
if (device == QString("nvidia")) {
|
if (device == QString("nvidia")) {
|
||||||
QString cmd = QString("nvidia-smi -q -d TEMPERATURE");
|
QString cmd = QString("nvidia-smi -q -d TEMPERATURE");
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||||
command.start(cmd);
|
processes[QString("gputemp")][0]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
|
||||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
|
||||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
|
||||||
.split(QChar(' '), QString::SkipEmptyParts)[2];
|
|
||||||
gpuTemp = temp.toFloat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (device == QString("ati")) {
|
else if (device == QString("ati")) {
|
||||||
QString cmd = QString("aticonfig --od-gettemperature");
|
QString cmd = QString("aticonfig --od-gettemperature");
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||||
command.start(cmd);
|
processes[QString("gputemp")][0]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
}
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::setGpuTemp()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setGpuTemp]";
|
||||||
|
float value = 0.0;
|
||||||
|
QString qoutput;
|
||||||
|
if (configuration[QString("GPUDEV")] == QString("nvidia")) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gputemp")][0]->readAllStandardOutput());
|
||||||
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||||
|
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||||
|
.split(QChar(' '), QString::SkipEmptyParts)[2];
|
||||||
|
value = temp.toFloat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (configuration[QString("GPUDEV")] == QString("ati")) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gputemp")][0]->readAllStandardOutput());
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
|
||||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||||
.split(QChar(' '), QString::SkipEmptyParts)[4];
|
.split(QChar(' '), QString::SkipEmptyParts)[4];
|
||||||
gpuTemp = temp.toFloat();
|
value = temp.toFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Return" << gpuTemp;
|
if (debug) qDebug() << "[DE]" << "[setGpuTemp]" << ":" << "Return" << value;
|
||||||
return gpuTemp;
|
QString source = QString("gputemp");
|
||||||
|
QString key = QString("GPUTemp");
|
||||||
|
setData(source, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
void ExtendedSysMon::getHddTemp(const QString cmd, const QString device, const int number)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]";
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]";
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with cmd" << cmd;
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device;
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device;
|
||||||
float hddTemp = 0.0;
|
|
||||||
QProcess command;
|
|
||||||
QString qoutput = QString("");
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
||||||
command.start(cmd + QString(" ") + device);
|
processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device);
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
|
||||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
|
||||||
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
|
||||||
temp.remove(QChar(0260)).remove(QChar('C'));
|
|
||||||
hddTemp = temp.toFloat();
|
|
||||||
}
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Return" << hddTemp;
|
|
||||||
return hddTemp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
void ExtendedSysMon::setHddTemp()
|
||||||
const QString mpdAddress,
|
{
|
||||||
const QString mpdPort)
|
if (debug) qDebug() << "[DE]" << "[setHddTemp]";
|
||||||
|
float value = 0.0;
|
||||||
|
QString qoutput = QString("");
|
||||||
|
for (int i=0; i<processes[QString("hddtemp")].count(); i++) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("hddtemp")][i]->readAllStandardOutput()).trimmed();
|
||||||
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||||
|
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
||||||
|
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||||
|
value = temp.toFloat();
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setHddTemp]" << ":" << "Found data for cmd" << i;
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setHddTemp]" << ":" << "Return" << value;
|
||||||
|
QString source = QString("hddtemp");
|
||||||
|
QString key = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts)[i];
|
||||||
|
setData(source, key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||||
|
const QString mpdAddress,
|
||||||
|
const QString mpdPort)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]";
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]";
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with player" << playerName;
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with player" << 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;
|
||||||
|
if (playerName == QString("amarok")) {
|
||||||
|
// amarok
|
||||||
|
cmd = QString("qdbus org.kde.amarok /Player GetMetadata");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("player")][0]->start(cmd);
|
||||||
|
cmd = QString("qdbus org.kde.amarok /Player PositionGet");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("player")][1]->start(cmd);
|
||||||
|
}
|
||||||
|
else if (playerName == QString("clementine")) {
|
||||||
|
// clementine
|
||||||
|
cmd = QString("qdbus org.mpris.clementine /Player GetMetadata");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("player")][0]->start(cmd);
|
||||||
|
cmd = QString("qdbus org.mpris.clementine /Player PositionGet");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("player")][1]->start(cmd);
|
||||||
|
}
|
||||||
|
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")) {
|
||||||
|
// qmmp
|
||||||
|
cmd = QString("qmmp --status");
|
||||||
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
processes[QString("player")][0]->start(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::setPlayer()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setPlayer]";
|
||||||
|
QString playerName = configuration[QString("PLAYER")];
|
||||||
|
QString qoutput = QString("");
|
||||||
|
QString qstr = QString("");
|
||||||
QStringList info;
|
QStringList info;
|
||||||
// album
|
// album
|
||||||
info.append(QString("unknown"));
|
info.append(QString("unknown"));
|
||||||
@ -377,85 +472,64 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
info.append(QString("0"));
|
info.append(QString("0"));
|
||||||
// title
|
// title
|
||||||
info.append(QString("unknown"));
|
info.append(QString("unknown"));
|
||||||
QProcess command;
|
|
||||||
QString cmd;
|
|
||||||
QString qoutput = QString("");
|
|
||||||
QString qstr;
|
|
||||||
if (playerName == QString("amarok")) {
|
if (playerName == QString("amarok")) {
|
||||||
// amarok
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
cmd = QString("qdbus org.kde.amarok /Player GetMetadata");
|
if (!qoutput.isEmpty()) {
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 0;
|
||||||
command.start(cmd);
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
command.waitForFinished(-1);
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
||||||
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||||
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
}
|
||||||
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
|
||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = QString("qdbus org.kde.amarok /Player PositionGet");
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][1]->readAllStandardOutput());
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (!qoutput.isEmpty()) {
|
||||||
command.start(cmd);
|
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 1;
|
||||||
command.waitForFinished(-1);
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
int time = qstr.toInt() / 1000;
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
info[2] = QString::number(time);
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
}
|
||||||
int time = qstr.toInt() / 1000;
|
|
||||||
info[2] = QString::number(time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (playerName == QString("clementine")) {
|
else if (playerName == QString("clementine")) {
|
||||||
// clementine
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
cmd = QString("qdbus org.mpris.clementine /Player GetMetadata");
|
if (!qoutput.isEmpty()) {
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 0;
|
||||||
command.start(cmd);
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
command.waitForFinished(-1);
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
||||||
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||||
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
}
|
||||||
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
|
||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = QString("qdbus org.mpris.clementine /Player PositionGet");
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][1]->readAllStandardOutput());
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (!qoutput.isEmpty()) {
|
||||||
command.start(cmd);
|
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 1;
|
||||||
command.waitForFinished(-1);
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
int time = qstr.toInt() / 1000;
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
info[2] = QString::number(time);
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
}
|
||||||
int time = qstr.toInt() / 1000;
|
|
||||||
info[2] = QString::number(time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (playerName == QString("mpd")) {
|
else if (playerName == QString("mpd")) {
|
||||||
// mpd
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
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;
|
|
||||||
command.start(cmd);
|
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
@ -473,13 +547,7 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (playerName == QString("qmmp")) {
|
else if (playerName == QString("qmmp")) {
|
||||||
// qmmp
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
cmd = QString("qmmp --status");
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
||||||
command.start(cmd);
|
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if ((qstr.split(QString(" = "), QString::SkipEmptyParts).count() > 1) || (qstr.at(0) == QChar('['))) {
|
if ((qstr.split(QString(" = "), QString::SkipEmptyParts).count() > 1) || (qstr.at(0) == QChar('['))) {
|
||||||
@ -499,63 +567,93 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Return" << info;
|
QString source = QString("player");
|
||||||
return info;
|
QString key;
|
||||||
|
key = QString("album");
|
||||||
|
setData(source, key, info[0]);
|
||||||
|
key = QString("artist");
|
||||||
|
setData(source, key, info[1]);
|
||||||
|
key = QString("progress");
|
||||||
|
setData(source, key, info[2]);
|
||||||
|
key = QString("duration");
|
||||||
|
setData(source, key, info[3]);
|
||||||
|
key = QString("title");
|
||||||
|
setData(source, key, info[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ExtendedSysMon::getPsStats()
|
void ExtendedSysMon::getPsStats()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]";
|
if (debug) qDebug() << "[DE]" << "[getPsStats]";
|
||||||
int psCount = 0;
|
|
||||||
QStringList psList;
|
|
||||||
QString cmd;
|
QString cmd;
|
||||||
QProcess command;
|
|
||||||
QString qoutput = QString("");
|
|
||||||
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;
|
||||||
command.start(cmd);
|
processes[QString("ps")][0]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
|
||||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i] != QString("ps --no-headers -o command")) {
|
|
||||||
psCount++;
|
|
||||||
psList.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
|
||||||
}
|
|
||||||
QStringList psStats;
|
|
||||||
psStats.append(QString::number(psCount));
|
|
||||||
psStats.append(psList.join(QString(",")));
|
|
||||||
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;
|
||||||
command.start(cmd);
|
processes[QString("ps")][1]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
|
||||||
int psTotal = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
|
||||||
psStats.append(QString::number(psTotal));
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Return" << psStats;
|
|
||||||
return psStats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int pkgNull)
|
void ExtendedSysMon::setPs()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setPs]";
|
||||||
|
QString qoutput = QString("");
|
||||||
|
for (int i=0; i<processes[QString("ps")].count(); i++) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("ps")][i]->readAllStandardOutput()).trimmed();
|
||||||
|
if (!qoutput.isEmpty()) {
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setPs]" << ":" << "Found data for cmd" << i;
|
||||||
|
if (i == 0) {
|
||||||
|
// pscount && ps
|
||||||
|
QStringList psList;
|
||||||
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
||||||
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i] != QString("ps --no-headers -o command"))
|
||||||
|
psList.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
||||||
|
QString source = QString("ps");
|
||||||
|
QString key = QString("psCount");
|
||||||
|
setData(source, key, QString::number(psList.count()));
|
||||||
|
key = QString("ps");
|
||||||
|
setData(source, key, psList.join(QString(",")));
|
||||||
|
}
|
||||||
|
else if (i == 1) {
|
||||||
|
// pstotal
|
||||||
|
QString source = QString("ps");
|
||||||
|
QString key = QString("psTotal");
|
||||||
|
setData(source, key, QString::number(qoutput.split(QChar('\n'), QString::SkipEmptyParts).count()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int number)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]";
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]";
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with cmd" << pkgCommand;
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with cmd" << pkgCommand;
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number of null lines" << pkgNull;
|
|
||||||
int count = 0;
|
|
||||||
QString cmd = QString("bash -c \"") + pkgCommand + QString("\"");
|
QString cmd = QString("bash -c \"") + pkgCommand + QString("\"");
|
||||||
QProcess command;
|
|
||||||
QString qoutput = QString("");
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||||
command.start(cmd);
|
processes[QString("pkg")][number]->start(cmd);
|
||||||
command.waitForFinished(-1);
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Cmd returns" << command.exitCode();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
|
||||||
count = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
void ExtendedSysMon::setUpgradeInfo()
|
||||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Return" << (count - pkgNull);
|
{
|
||||||
return (count - pkgNull);
|
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]";
|
||||||
|
int pkgNull = 0;
|
||||||
|
int value = 0;
|
||||||
|
QString qoutput = QString("");
|
||||||
|
for (int i=0; i<processes[QString("pkg")].count(); i++) {
|
||||||
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("pkg")][i]->readAllStandardOutput()).trimmed();
|
||||||
|
if (!qoutput.isEmpty()) {
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]" << ":" << "Found data for cmd" << i;
|
||||||
|
pkgNull = configuration[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts)[i].toInt();
|
||||||
|
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]" << ":" << "Return" << value;
|
||||||
|
QString source = QString("pkg");
|
||||||
|
QString key = QString("pkgCount") + QString::number(i);
|
||||||
|
setData(source, key, value - pkgNull);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -578,55 +676,29 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (source == QString("gpu")) {
|
else if (source == QString("gpu")) {
|
||||||
key = QString("GPU");
|
getGpu(configuration[QString("GPUDEV")]);
|
||||||
float value = getGpu(configuration[QString("GPUDEV")]);
|
|
||||||
setData(source, key, value);
|
|
||||||
}
|
}
|
||||||
else if (source == QString("gputemp")) {
|
else if (source == QString("gputemp")) {
|
||||||
key = QString("GPUTemp");
|
getGpuTemp(configuration[QString("GPUDEV")]);
|
||||||
float value = getGpuTemp(configuration[QString("GPUDEV")]);
|
|
||||||
setData(source, key, value);
|
|
||||||
}
|
}
|
||||||
else if (source == QString("hddtemp")) {
|
else if (source == QString("hddtemp")) {
|
||||||
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<deviceList.count(); i++) {
|
for (int i=0; i<deviceList.count(); i++) {
|
||||||
float value = getHddTemp(configuration[QString("HDDTEMPCMD")],
|
getHddTemp(configuration[QString("HDDTEMPCMD")], deviceList[i], i);
|
||||||
deviceList[i]);
|
|
||||||
setData(source, deviceList[i], value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (source == QString("pkg")) {
|
else if (source == QString("pkg")) {
|
||||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
||||||
key = QString("pkgCount") + QString::number(i);
|
getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i], i);
|
||||||
int value = getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i],
|
|
||||||
configuration[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts)[i].toInt());
|
|
||||||
setData(source, key, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (source == QString("player")) {
|
else if (source == QString("player")) {
|
||||||
QStringList value;
|
getPlayerInfo(configuration[QString("PLAYER")],
|
||||||
value = getPlayerInfo(configuration[QString("PLAYER")],
|
configuration[QString("MPDADDRESS")],
|
||||||
configuration[QString("MPDADDRESS")],
|
configuration[QString("MPDPORT")]);
|
||||||
configuration[QString("MPDPORT")]);
|
|
||||||
key = QString("album");
|
|
||||||
setData(source, key, value[0]);
|
|
||||||
key = QString("artist");
|
|
||||||
setData(source, key, value[1]);
|
|
||||||
key = QString("progress");
|
|
||||||
setData(source, key, value[2]);
|
|
||||||
key = QString("duration");
|
|
||||||
setData(source, key, value[3]);
|
|
||||||
key = QString("title");
|
|
||||||
setData(source, key, value[4]);
|
|
||||||
}
|
}
|
||||||
else if (source == QString("ps")) {
|
else if (source == QString("ps")) {
|
||||||
QStringList value = getPsStats();
|
getPsStats();
|
||||||
key = QString("psCount");
|
|
||||||
setData(source, key, value[0].toInt());
|
|
||||||
key = QString("ps");
|
|
||||||
setData(source, key, value[1]);
|
|
||||||
key = QString("psTotal");
|
|
||||||
setData(source, key, value[2].toInt());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,16 +29,18 @@ class ExtendedSysMon : public Plasma::DataEngine
|
|||||||
public:
|
public:
|
||||||
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||||
// update functions
|
// update functions
|
||||||
void getCustomCmd(const QString cmd, const int number);
|
void getCustomCmd(const QString cmd,
|
||||||
float getGpu(const QString device);
|
const int number = 0);
|
||||||
float getGpuTemp(const QString device);
|
void getGpu(const QString device);
|
||||||
float getHddTemp(const QString cmd, const QString device);
|
void getGpuTemp(const QString device);
|
||||||
QStringList getPlayerInfo(const QString playerName,
|
void getHddTemp(const QString cmd, const QString device,
|
||||||
const QString mpdAddress = 0,
|
const int number = 0);
|
||||||
const QString mpdPort = 0);
|
void getPlayerInfo(const QString playerName,
|
||||||
QStringList getPsStats();
|
const QString mpdAddress = 0,
|
||||||
int getUpgradeInfo(const QString pkgCommand,
|
const QString mpdPort = 0);
|
||||||
const int pkgNull = 0);
|
void getPsStats();
|
||||||
|
void getUpgradeInfo(const QString pkgCommand,
|
||||||
|
const int number = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool sourceRequestEvent(const QString &name);
|
bool sourceRequestEvent(const QString &name);
|
||||||
@ -47,10 +49,16 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setCustomCmd();
|
void setCustomCmd();
|
||||||
|
void setGpu();
|
||||||
|
void setGpuTemp();
|
||||||
|
void setHddTemp();
|
||||||
|
void setUpgradeInfo();
|
||||||
|
void setPlayer();
|
||||||
|
void setPs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// processes
|
// processes
|
||||||
QList<QProcess*> customProcesses;
|
QMap<QString, QList<QProcess*> > processes;
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
bool debug;
|
bool debug;
|
||||||
@ -58,7 +66,7 @@ private:
|
|||||||
QString getAllHdd();
|
QString getAllHdd();
|
||||||
QString getAutoGpu();
|
QString getAutoGpu();
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
void setCustomProcesses();
|
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