mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
add debug support in DataEngine
This commit is contained in:
parent
2201f4d4a2
commit
31c612cfd2
@ -8,6 +8,7 @@ Ver.1.10.0:
|
|||||||
+ added error checking of DataEngine variables
|
+ added error checking of DataEngine variables
|
||||||
+ added ability to disable popup messages
|
+ added ability to disable popup messages
|
||||||
+ added ability to use vertical layout
|
+ added ability to use vertical layout
|
||||||
|
+ added ability to show debug information in DataEngine
|
||||||
+ added Brazillian Portuguese translation (@underr)
|
+ added Brazillian Portuguese translation (@underr)
|
||||||
+ added Ukrainian translation (Виктор Слободян)
|
+ added Ukrainian translation (Виктор Слободян)
|
||||||
- removed util.py
|
- removed util.py
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
+ добавлена проверка ошибок для переменных DataEngine
|
+ добавлена проверка ошибок для переменных DataEngine
|
||||||
+ добавлена возможность отключения всплывающих сообщений
|
+ добавлена возможность отключения всплывающих сообщений
|
||||||
+ добавлена возможность использовать вертикальную разметку
|
+ добавлена возможность использовать вертикальную разметку
|
||||||
|
+ добавлена возможность вывод отладочной информации в DataEngine
|
||||||
+ добавлен перевод Brazillian Portuguese (@underr)
|
+ добавлен перевод Brazillian Portuguese (@underr)
|
||||||
+ добавлена украинская локализация (Виктор Слободян)
|
+ добавлена украинская локализация (Виктор Слободян)
|
||||||
- удален util.py
|
- удален util.py
|
||||||
|
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=('658be821632a8be9aa594765e4f14939')
|
md5sums=('7366d3a97c2426f3ffe769e74f83a86b')
|
||||||
backup=('usr/share/config/extsysmon.conf')
|
backup=('usr/share/config/extsysmon.conf')
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
|
@ -30,3 +30,6 @@
|
|||||||
|
|
||||||
# Player name. Supported players are amarok, clementine, mpd, qmmp
|
# Player name. Supported players are amarok, clementine, mpd, qmmp
|
||||||
#PLAYER=amarok
|
#PLAYER=amarok
|
||||||
|
|
||||||
|
# Enable some debug information (yes or no)
|
||||||
|
#DEBUG=no
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <Plasma/DataContainer>
|
#include <Plasma/DataContainer>
|
||||||
#include <KDE/KGlobal>
|
#include <KDE/KGlobal>
|
||||||
#include <KDE/KStandardDirs>
|
#include <KDE/KStandardDirs>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
@ -33,47 +34,54 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
|||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
|
|
||||||
setMinimumPollingInterval(333);
|
setMinimumPollingInterval(333);
|
||||||
|
debug = true;
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtendedSysMon::getAllHdd()
|
QString ExtendedSysMon::getAllHdd()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getAllHdd]";
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QStringList devices;
|
QStringList devices;
|
||||||
|
QString cmd = QString("find /dev -name [hms]d[a-z]");
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
QString dev;
|
if (debug) qDebug() << "[getAllHdd]" << ":" << "Run cmd" << cmd;
|
||||||
command.start("find /dev -name [hms]d[a-z]");
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
#include <QDebug>
|
if (debug) qDebug() << "[getAllHdd]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qDebug() << command.readAllStandardError();
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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++)
|
||||||
dev = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
devices.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
||||||
devices.append(dev);
|
if (debug) qDebug() << "[getAllHdd]" << ":" << "Device list" << devices;
|
||||||
}
|
|
||||||
return devices.join(QChar(','));
|
return devices.join(QChar(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtendedSysMon::getAutoGpu()
|
QString ExtendedSysMon::getAutoGpu()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getAutoGpu]";
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString gpu = QString("disable");
|
QString gpu = QString("disable");
|
||||||
|
QString cmd = QString("lspci");
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
command.start("lspci");
|
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||||
if (qoutput.toLower().contains("nvidia"))
|
if (qoutput.toLower().contains("nvidia"))
|
||||||
gpu = QString("nvidia");
|
gpu = QString("nvidia");
|
||||||
else if (qoutput.toLower().contains("radeon"))
|
else if (qoutput.toLower().contains("radeon"))
|
||||||
gpu = QString("ati");
|
gpu = QString("ati");
|
||||||
|
if (debug) qDebug() << "[getAutoGpu]" << ":" << "Device" << gpu;
|
||||||
return gpu;
|
return gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ExtendedSysMon::sources() const
|
QStringList ExtendedSysMon::sources() const
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[sources]";
|
||||||
QStringList source;
|
QStringList source;
|
||||||
source.append(QString("custom"));
|
source.append(QString("custom"));
|
||||||
source.append(QString("gpu"));
|
source.append(QString("gpu"));
|
||||||
@ -82,15 +90,18 @@ QStringList ExtendedSysMon::sources() const
|
|||||||
source.append(QString("pkg"));
|
source.append(QString("pkg"));
|
||||||
source.append(QString("player"));
|
source.append(QString("player"));
|
||||||
source.append(QString("ps"));
|
source.append(QString("ps"));
|
||||||
|
if (debug) qDebug() << "[sources]" << ":" << "Sources" << source;
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::readConfiguration()
|
void ExtendedSysMon::readConfiguration()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[readConfiguration]";
|
||||||
// pre-setup
|
// pre-setup
|
||||||
QMap<QString, QString> rawConfig;
|
QMap<QString, QString> rawConfig;
|
||||||
rawConfig[QString("CUSTOM")] = QString("wget -qO- http://ifconfig.me/ip");
|
rawConfig[QString("CUSTOM")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||||
|
rawConfig[QString("DEBUG")] = QString("no");
|
||||||
rawConfig[QString("GPUDEV")] = QString("auto");
|
rawConfig[QString("GPUDEV")] = QString("auto");
|
||||||
rawConfig[QString("HDDDEV")] = QString("all");
|
rawConfig[QString("HDDDEV")] = QString("all");
|
||||||
rawConfig[QString("HDDTEMPCMD")] = QString("sudo hddtemp");
|
rawConfig[QString("HDDTEMPCMD")] = QString("sudo hddtemp");
|
||||||
@ -101,6 +112,7 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
rawConfig[QString("PLAYER")] = QString("amarok");
|
rawConfig[QString("PLAYER")] = QString("amarok");
|
||||||
|
|
||||||
QString fileName = KGlobal::dirs()->findResource("config", "extsysmon.conf");
|
QString fileName = KGlobal::dirs()->findResource("config", "extsysmon.conf");
|
||||||
|
if (debug) qDebug() << "[readConfiguration]" << ":" << "Configuration file" << fileName;
|
||||||
QFile confFile(fileName);
|
QFile confFile(fileName);
|
||||||
bool ok = confFile.open(QIODevice::ReadOnly);
|
bool ok = confFile.open(QIODevice::ReadOnly);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -124,12 +136,12 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
}
|
}
|
||||||
confFile.close();
|
confFile.close();
|
||||||
configuration = updateConfiguration(rawConfig);
|
configuration = updateConfiguration(rawConfig);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, QString> rawConfig)
|
QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[updateConfiguration]";
|
||||||
QMap<QString, QString> config;
|
QMap<QString, QString> config;
|
||||||
QString key, value;
|
QString key, value;
|
||||||
// remove spaces and copy source map
|
// remove spaces and copy source map
|
||||||
@ -142,6 +154,13 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, Q
|
|||||||
config[key] = value;
|
config[key] = value;
|
||||||
}
|
}
|
||||||
// update values
|
// update values
|
||||||
|
// debug
|
||||||
|
if ((config[QString("DEBUG")] != QString("yes")) &&
|
||||||
|
(config[QString("DEBUG")] != QString("no")))
|
||||||
|
config[QString("DEBUG")] = QString("no");
|
||||||
|
if (config[QString("DEBUG")] == QString("no"))
|
||||||
|
debug = false;
|
||||||
|
// gpudev
|
||||||
if (config[QString("GPUDEV")] == QString("disable"))
|
if (config[QString("GPUDEV")] == QString("disable"))
|
||||||
config[QString("GPUDEV")] = QString("disable");
|
config[QString("GPUDEV")] = QString("disable");
|
||||||
else if (config[QString("GPUDEV")] == QString("auto"))
|
else if (config[QString("GPUDEV")] == QString("auto"))
|
||||||
@ -149,6 +168,7 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, Q
|
|||||||
else if ((config[QString("GPUDEV")] != QString("ati")) &&
|
else if ((config[QString("GPUDEV")] != QString("ati")) &&
|
||||||
(config[QString("GPUDEV")] != QString("nvidia")))
|
(config[QString("GPUDEV")] != QString("nvidia")))
|
||||||
config[QString("GPUDEV")] = getAutoGpu();
|
config[QString("GPUDEV")] = getAutoGpu();
|
||||||
|
// hdddev
|
||||||
if (config[QString("HDDDEV")] == QString("all"))
|
if (config[QString("HDDDEV")] == QString("all"))
|
||||||
config[QString("HDDDEV")] = getAllHdd();
|
config[QString("HDDDEV")] = getAllHdd();
|
||||||
else if (config[QString("HDDDEV")] == QString("disable"))
|
else if (config[QString("HDDDEV")] == QString("disable"))
|
||||||
@ -166,32 +186,45 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, Q
|
|||||||
else
|
else
|
||||||
config[QString("HDDDEV")] = devices.join(QChar(','));
|
config[QString("HDDDEV")] = devices.join(QChar(','));
|
||||||
}
|
}
|
||||||
|
// pkgcmd
|
||||||
for (int i=config[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts).count();
|
for (int i=config[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts).count();
|
||||||
i<config[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count()+1;
|
i<config[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count()+1;
|
||||||
i++)
|
i++)
|
||||||
config[QString("PKGNULL")] += QString(",0");
|
config[QString("PKGNULL")] += QString(",0");
|
||||||
|
// player
|
||||||
if ((config[QString("PLAYER")] != QString("amarok")) &&
|
if ((config[QString("PLAYER")] != QString("amarok")) &&
|
||||||
(config[QString("PLAYER")] != QString("clementine")) &&
|
(config[QString("PLAYER")] != QString("clementine")) &&
|
||||||
(config[QString("PLAYER")] != QString("mpd")) &&
|
(config[QString("PLAYER")] != QString("mpd")) &&
|
||||||
(config[QString("PLAYER")] != QString("qmmp")))
|
(config[QString("PLAYER")] != QString("qmmp")))
|
||||||
config[QString("PLAYER")] = QString("amarok");
|
config[QString("PLAYER")] = QString("amarok");
|
||||||
|
|
||||||
|
for (int i=0; i<config.keys().count(); i++)
|
||||||
|
if (debug) qDebug() << "[updateConfiguration]" << ":" <<
|
||||||
|
config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtendedSysMon::getCustomCmd(const QString cmd)
|
QString ExtendedSysMon::getCustomCmd(const QString cmd)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getCustomCmd]";
|
||||||
|
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
|
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
||||||
command.start(QString("bash -c \"") + cmd + QString("\""));
|
command.start(QString("bash -c \"") + cmd + QString("\""));
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||||
|
if (debug) qDebug() << "[getCustomCmd]" << ":" << "Return" << qoutput;
|
||||||
return qoutput;
|
return qoutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getGpu(const QString device)
|
float ExtendedSysMon::getGpu(const QString device)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getGpu]";
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Run function with device" << device;
|
||||||
float gpu = 0.0;
|
float gpu = 0.0;
|
||||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||||
return gpu;
|
return gpu;
|
||||||
@ -199,8 +232,11 @@ float ExtendedSysMon::getGpu(const QString device)
|
|||||||
QString qoutput;
|
QString qoutput;
|
||||||
|
|
||||||
if (device == QString("nvidia")) {
|
if (device == QString("nvidia")) {
|
||||||
command.start(QString("nvidia-smi -q -d UTILIZATION"));
|
QString cmd = QString("nvidia-smi -q -d UTILIZATION");
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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("Gpu"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||||
@ -212,8 +248,11 @@ float ExtendedSysMon::getGpu(const QString device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (device == QString("ati")) {
|
else if (device == QString("ati")) {
|
||||||
command.start(QString("aticonfig --od-getclocks"));
|
QString cmd = QString("aticonfig --od-getclocks");
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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"))) {
|
||||||
@ -224,20 +263,27 @@ float ExtendedSysMon::getGpu(const QString device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (debug) qDebug() << "[getGpu]" << ":" << "Return" << gpu;
|
||||||
return gpu;
|
return gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getGpuTemp(const QString device)
|
float ExtendedSysMon::getGpuTemp(const QString device)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]";
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
||||||
float gpuTemp = 0.0;
|
float gpuTemp = 0.0;
|
||||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||||
return gpuTemp;
|
return gpuTemp;
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString qoutput;
|
QString qoutput;
|
||||||
|
|
||||||
if (device == QString("nvidia")) {
|
if (device == QString("nvidia")) {
|
||||||
command.start(QString("nvidia-smi -q -d TEMPERATURE"));
|
QString cmd = QString("nvidia-smi -q -d TEMPERATURE");
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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("Gpu"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||||
@ -248,8 +294,11 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (device == QString("ati")) {
|
else if (device == QString("ati")) {
|
||||||
command.start(QString("aticonfig --od-gettemperature"));
|
QString cmd = QString("aticonfig --od-gettemperature");
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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("Temperature"))) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
|
||||||
@ -259,23 +308,30 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (debug) qDebug() << "[getGpuTemp]" << ":" << "Return" << gpuTemp;
|
||||||
return gpuTemp;
|
return gpuTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
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;
|
||||||
float hddTemp = 0.0;
|
float hddTemp = 0.0;
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
|
if (debug) qDebug() << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
||||||
command.start(cmd + QString(" ") + device);
|
command.start(cmd + QString(" ") + device);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getHddTemp]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||||
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
||||||
temp.remove(QChar(0260)).remove(QChar('C'));
|
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||||
hddTemp = temp.toFloat();
|
hddTemp = temp.toFloat();
|
||||||
}
|
}
|
||||||
|
if (debug) qDebug() << "[getHddTemp]" << ":" << "Return" << hddTemp;
|
||||||
return hddTemp;
|
return hddTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +340,10 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
const QString mpdAddress,
|
const QString mpdAddress,
|
||||||
const QString mpdPort)
|
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" <<
|
||||||
|
mpdAddress + QString(":") + mpdPort;
|
||||||
QStringList info;
|
QStringList info;
|
||||||
// album
|
// album
|
||||||
info.append(QString("unknown"));
|
info.append(QString("unknown"));
|
||||||
@ -296,12 +356,16 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
// title
|
// title
|
||||||
info.append(QString("unknown"));
|
info.append(QString("unknown"));
|
||||||
QProcess command;
|
QProcess command;
|
||||||
|
QString cmd;
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
QString qstr;
|
QString qstr;
|
||||||
if (playerName == QString("amarok")) {
|
if (playerName == QString("amarok")) {
|
||||||
// amarok
|
// amarok
|
||||||
command.start("qdbus org.kde.amarok /Player GetMetadata");
|
cmd = QString("qdbus org.kde.amarok /Player GetMetadata");
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -316,8 +380,11 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command.start("qdbus org.kde.amarok /Player PositionGet");
|
cmd = QString("qdbus org.kde.amarok /Player PositionGet");
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -327,8 +394,11 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
else if (playerName == QString("clementine")) {
|
else if (playerName == QString("clementine")) {
|
||||||
// clementine
|
// clementine
|
||||||
command.start("qdbus org.mpris.clementine /Player GetMetadata");
|
cmd = QString("qdbus org.mpris.clementine /Player GetMetadata");
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -343,8 +413,11 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command.start("qdbus org.mpris.clementine /Player PositionGet");
|
cmd = QString("qdbus org.mpris.clementine /Player PositionGet");
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -354,9 +427,12 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
else if (playerName == QString("mpd")) {
|
else if (playerName == QString("mpd")) {
|
||||||
// mpd
|
// mpd
|
||||||
command.start(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() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -376,8 +452,11 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
else if (playerName == QString("qmmp")) {
|
else if (playerName == QString("qmmp")) {
|
||||||
// qmmp
|
// qmmp
|
||||||
command.start("qmmp --status");
|
cmd = QString("qmmp --status");
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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];
|
||||||
@ -398,18 +477,24 @@ QStringList ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (debug) qDebug() << "[getPlayerInfo]" << ":" << "Return" << info;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ExtendedSysMon::getPsStats()
|
QStringList ExtendedSysMon::getPsStats()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[getPsStats]";
|
||||||
int psCount = 0;
|
int psCount = 0;
|
||||||
QStringList psList;
|
QStringList psList;
|
||||||
|
QString cmd;
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
command.start(QString("ps --no-headers -o command"));
|
cmd = QString("ps --no-headers -o command");
|
||||||
|
if (debug) qDebug() << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||||
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] != QString("ps --no-headers -o command")) {
|
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i] != QString("ps --no-headers -o command")) {
|
||||||
@ -419,36 +504,51 @@ QStringList ExtendedSysMon::getPsStats()
|
|||||||
QStringList psStats;
|
QStringList psStats;
|
||||||
psStats.append(QString::number(psCount));
|
psStats.append(QString::number(psCount));
|
||||||
psStats.append(psList.join(QString(",")));
|
psStats.append(psList.join(QString(",")));
|
||||||
command.start(QString("ps -e --no-headers -o command"));
|
cmd = QString("ps -e --no-headers -o command");
|
||||||
|
if (debug) qDebug() << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getPsStats]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||||
int psTotal = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
int psTotal = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
||||||
psStats.append(QString::number(psTotal));
|
psStats.append(QString::number(psTotal));
|
||||||
|
if (debug) qDebug() << "[getPsStats]" << ":" << "Return" << psStats;
|
||||||
return psStats;
|
return psStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int pkgNull)
|
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;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
QString cmd = QString("bash -c \"") + pkgCommand + QString("\"");
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
command.start(QString("bash -c \"") + pkgCommand + QString("\""));
|
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||||
|
command.start(cmd);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed();
|
||||||
count = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
count = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
||||||
|
if (debug) qDebug() << "[getUpgradeInfo]" << ":" << "Return" << (count - pkgNull);
|
||||||
return (count - pkgNull);
|
return (count - pkgNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
|
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[sourceRequestEvent]";
|
||||||
|
if (debug) qDebug() << "[sourceRequestEvent]" << ":" << "Run function with source name" << name;
|
||||||
return updateSourceEvent(name);
|
return updateSourceEvent(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[updateSourceEvent]";
|
||||||
|
if (debug) qDebug() << "[updateSourceEvent]" << ":" << "Run function with source name" << source;
|
||||||
QString key;
|
QString key;
|
||||||
if (source == QString("custom")) {
|
if (source == QString("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++) {
|
||||||
|
@ -46,6 +46,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
|
bool debug;
|
||||||
// reread configuration
|
// reread configuration
|
||||||
QString getAllHdd();
|
QString getAllHdd();
|
||||||
QString getAutoGpu();
|
QString getAutoGpu();
|
||||||
|
Loading…
Reference in New Issue
Block a user