mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
add support of debug to widget
This commit is contained in:
@ -36,7 +36,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("PTM_DE_DEBUG"), QString("no"));
|
||||
QString debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
@ -49,47 +49,47 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||
|
||||
QString ExtendedSysMon::getAllHdd()
|
||||
{
|
||||
if (debug) qDebug() << "[getAllHdd]";
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]";
|
||||
QProcess command;
|
||||
QStringList devices;
|
||||
QString cmd = QString("find /dev -name [hms]d[a-z]");
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[getAllHdd]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getAllHdd]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Cmd returns" << command.exitCode();
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
||||
devices.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
||||
if (debug) qDebug() << "[getAllHdd]" << ":" << "Device list" << devices;
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Device list" << devices;
|
||||
return devices.join(QChar(','));
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAutoGpu()
|
||||
{
|
||||
if (debug) qDebug() << "[getAutoGpu]";
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]";
|
||||
QProcess command;
|
||||
QString gpu = QString("disable");
|
||||
QString cmd = QString("lspci");
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
if (qoutput.toLower().contains("nvidia"))
|
||||
gpu = QString("nvidia");
|
||||
else if (qoutput.toLower().contains("radeon"))
|
||||
gpu = QString("ati");
|
||||
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Device" << gpu;
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Device" << gpu;
|
||||
return gpu;
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtendedSysMon::sources() const
|
||||
{
|
||||
if (debug) qDebug() << "[sources]";
|
||||
if (debug) qDebug() << "[DE]" << "[sources]";
|
||||
QStringList source;
|
||||
source.append(QString("custom"));
|
||||
source.append(QString("gpu"));
|
||||
@ -98,14 +98,14 @@ QStringList ExtendedSysMon::sources() const
|
||||
source.append(QString("pkg"));
|
||||
source.append(QString("player"));
|
||||
source.append(QString("ps"));
|
||||
if (debug) qDebug() << "[sources]" << ":" << "Sources" << source;
|
||||
if (debug) qDebug() << "[DE]" << "[sources]" << ":" << "Sources" << source;
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << "[readConfiguration]";
|
||||
if (debug) qDebug() << "[DE]" << "[readConfiguration]";
|
||||
// pre-setup
|
||||
QMap<QString, QString> rawConfig;
|
||||
rawConfig[QString("CUSTOM")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||
@ -119,7 +119,7 @@ void ExtendedSysMon::readConfiguration()
|
||||
rawConfig[QString("PLAYER")] = QString("amarok");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "extsysmon.conf");
|
||||
if (debug) qDebug() << "[readConfiguration]" << ":" << "Configuration file" << fileName;
|
||||
if (debug) qDebug() << "[DE]" << "[readConfiguration]" << ":" << "Configuration file" << fileName;
|
||||
QFile confFile(fileName);
|
||||
bool ok = confFile.open(QIODevice::ReadOnly);
|
||||
if (!ok) {
|
||||
@ -148,7 +148,7 @@ void ExtendedSysMon::readConfiguration()
|
||||
|
||||
QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << "[updateConfiguration]";
|
||||
if (debug) qDebug() << "[DE]" << "[updateConfiguration]";
|
||||
QMap<QString, QString> config;
|
||||
QString key, value;
|
||||
// remove spaces and copy source map
|
||||
@ -200,7 +200,7 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, Q
|
||||
config[QString("PLAYER")] = QString("amarok");
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << "[updateConfiguration]" << ":" <<
|
||||
if (debug) qDebug() << "[DE]" << "[updateConfiguration]" << ":" <<
|
||||
config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||
return config;
|
||||
}
|
||||
@ -208,24 +208,24 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, Q
|
||||
|
||||
QString ExtendedSysMon::getCustomCmd(const QString cmd)
|
||||
{
|
||||
if (debug) qDebug() << "[getCustomCmd]";
|
||||
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]";
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
||||
QProcess command;
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
||||
command.start(QString("bash -c \"") + cmd + QString("\""));
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Cmd returns" << command.exitCode();
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Return" << qoutput;
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Return" << qoutput;
|
||||
return qoutput;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getGpu(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << "[getGpu]";
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Run function with device" << device;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]";
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run function with device" << device;
|
||||
float gpu = 0.0;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return gpu;
|
||||
@ -234,10 +234,10 @@ float ExtendedSysMon::getGpu(const QString device)
|
||||
|
||||
if (device == QString("nvidia")) {
|
||||
QString cmd = QString("nvidia-smi -q -d UTILIZATION");
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||
@ -250,10 +250,10 @@ float ExtendedSysMon::getGpu(const QString device)
|
||||
}
|
||||
else if (device == QString("ati")) {
|
||||
QString cmd = QString("aticonfig --od-getclocks");
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
|
||||
@ -264,15 +264,15 @@ float ExtendedSysMon::getGpu(const QString device)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) qDebug() << "[getGpu]" << ":" << "Return" << gpu;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Return" << gpu;
|
||||
return gpu;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << "[getGpuTemp]";
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
||||
float gpuTemp = 0.0;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return gpuTemp;
|
||||
@ -281,10 +281,10 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
|
||||
if (device == QString("nvidia")) {
|
||||
QString cmd = QString("nvidia-smi -q -d TEMPERATURE");
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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"))) {
|
||||
@ -296,10 +296,10 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
}
|
||||
else if (device == QString("ati")) {
|
||||
QString cmd = QString("aticonfig --od-gettemperature");
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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("Temperature"))) {
|
||||
@ -309,30 +309,30 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Return" << gpuTemp;
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Return" << gpuTemp;
|
||||
return gpuTemp;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
||||
{
|
||||
if (debug) qDebug() << "[getHddTemp]";
|
||||
if (debug) qDebug() << "[getHddTemp]" << ":" << "Run function with cmd" << cmd;
|
||||
if (debug) qDebug() << "[getHddTemp]" << ":" << "Run function with device" << device;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device;
|
||||
float hddTemp = 0.0;
|
||||
QProcess command;
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
||||
command.start(cmd + QString(" ") + device);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getHddTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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() << "[getHddTemp]" << ":" << "Return" << hddTemp;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Return" << hddTemp;
|
||||
return hddTemp;
|
||||
}
|
||||
|
||||
@ -341,9 +341,9 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress,
|
||||
const QString mpdPort)
|
||||
{
|
||||
if (debug) qDebug() << "[getPlayerInfo]";
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run function with player" << playerName;
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" <<
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]";
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with player" << playerName;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" <<
|
||||
mpdAddress + QString(":") + mpdPort;
|
||||
QStringList info;
|
||||
// album
|
||||
@ -363,10 +363,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
if (playerName == QString("amarok")) {
|
||||
// amarok
|
||||
cmd = QString("qdbus org.kde.amarok /Player GetMetadata");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -382,10 +382,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
}
|
||||
}
|
||||
cmd = QString("qdbus org.kde.amarok /Player PositionGet");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -396,10 +396,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
else if (playerName == QString("clementine")) {
|
||||
// clementine
|
||||
cmd = QString("qdbus org.mpris.clementine /Player GetMetadata");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -415,10 +415,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
}
|
||||
}
|
||||
cmd = QString("qdbus org.mpris.clementine /Player PositionGet");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -430,10 +430,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
// mpd
|
||||
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") +
|
||||
mpdAddress + QString(":") + mpdPort + QString("\"");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -454,10 +454,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
else if (playerName == QString("qmmp")) {
|
||||
// qmmp
|
||||
cmd = QString("qmmp --status");
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
@ -478,24 +478,24 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Return" << info;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Return" << info;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << "[getPsStats]";
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]";
|
||||
int psCount = 0;
|
||||
QStringList psList;
|
||||
QString cmd;
|
||||
QProcess command;
|
||||
QString qoutput = QString("");
|
||||
cmd = QString("ps --no-headers -o command");
|
||||
if (debug) qDebug() << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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")) {
|
||||
@ -506,50 +506,50 @@ QStringList ExtendedSysMon::getPsStats()
|
||||
psStats.append(QString::number(psCount));
|
||||
psStats.append(psList.join(QString(",")));
|
||||
cmd = QString("ps -e --no-headers -o command");
|
||||
if (debug) qDebug() << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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() << "[getPsStats]" << ":" << "Return" << psStats;
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Return" << psStats;
|
||||
return psStats;
|
||||
}
|
||||
|
||||
|
||||
int ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int pkgNull)
|
||||
{
|
||||
if (debug) qDebug() << "[getUpgradeInfo]";
|
||||
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Run function with cmd" << pkgCommand;
|
||||
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Run function with number of null lines" << pkgNull;
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]";
|
||||
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("\"");
|
||||
QProcess command;
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||
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();
|
||||
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Return" << (count - pkgNull);
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Return" << (count - pkgNull);
|
||||
return (count - pkgNull);
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (debug) qDebug() << "[sourceRequestEvent]";
|
||||
if (debug) qDebug() << "[sourceRequestEvent]" << ":" << "Run function with source name" << name;
|
||||
if (debug) qDebug() << "[DE]" << "[sourceRequestEvent]";
|
||||
if (debug) qDebug() << "[DE]" << "[sourceRequestEvent]" << ":" << "Run function with source name" << name;
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
{
|
||||
if (debug) qDebug() << "[updateSourceEvent]";
|
||||
if (debug) qDebug() << "[updateSourceEvent]" << ":" << "Run function with source name" << source;
|
||||
if (debug) qDebug() << "[DE]" << "[updateSourceEvent]";
|
||||
if (debug) qDebug() << "[DE]" << "[updateSourceEvent]" << ":" << "Run function with source name" << source;
|
||||
QString key;
|
||||
if (source == QString("custom")) {
|
||||
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
||||
|
Reference in New Issue
Block a user