mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
move extsysmon and plugin to the new source model
This commit is contained in:
parent
ab0ab0d40f
commit
9e45b02c8e
@ -16,7 +16,7 @@ include_directories(
|
|||||||
|
|
||||||
file(GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
file(GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||||
file(RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
file(RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||||
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
file(GLOB SUBPROJECT_SOURCE *.cpp sources/*.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
||||||
set(TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
set(TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||||
file(GLOB SUBPROJECT_CONF *.conf)
|
file(GLOB SUBPROJECT_CONF *.conf)
|
||||||
file(GLOB SUBPROJECT_INI *.ini)
|
file(GLOB SUBPROJECT_INI *.ini)
|
||||||
|
78
sources/extsysmon/extsysmonaggregator.cpp
Normal file
78
sources/extsysmon/extsysmonaggregator.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "extsysmonaggregator.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtSysMonAggregator::ExtSysMonAggregator(QObject *parent, const QHash<QString, QString> config)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
init(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtSysMonAggregator::~ExtSysMonAggregator()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant ExtSysMonAggregator::data(const QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
return m_map.contains(source) ? m_map[source]->data(source) : QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtSysMonSource *ExtSysMonAggregator::engine(const QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
return m_map.contains(source) ? m_map[source] : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap ExtSysMonAggregator::initialData(const QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
return m_map.contains(source) ? m_map[source]->initialData(source) : QVariantMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList ExtSysMonAggregator::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_map.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtSysMonAggregator::init(const QHash<QString, QString> config)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
44
sources/extsysmon/extsysmonaggregator.h
Normal file
44
sources/extsysmon/extsysmonaggregator.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef EXTSYSMONAGGREGATOR_H
|
||||||
|
#define EXTSYSMONAGGREGATOR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "sources/abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ExtSysMonAggregator : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExtSysMonAggregator(QObject *parent, const QHash<QString, QString> config);
|
||||||
|
virtual ~ExtSysMonAggregator();
|
||||||
|
QVariant data(const QString source) const;
|
||||||
|
AbstractExtSysMonSource *engine(const QString source);
|
||||||
|
QVariantMap initialData(const QString source) const;
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init(const QHash<QString, QString> config);
|
||||||
|
QHash<QString, AbstractExtSysMonSource *> m_map;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXTSYSMONAGGREGATOR_H */
|
45
sources/extsysmon/sources/abstractextsysmonsource.h
Normal file
45
sources/extsysmon/sources/abstractextsysmonsource.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ABSTRACTEXTSYSMONSOURCE_H
|
||||||
|
#define ABSTRACTEXTSYSMONSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractExtSysMonSource : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AbstractExtSysMonSource(QObject *parent, const QStringList) : QObject(parent) {};
|
||||||
|
virtual ~AbstractExtSysMonSource() {};
|
||||||
|
virtual QVariant data(QString source) = 0;
|
||||||
|
virtual QVariantMap initialData(QString source) const = 0;
|
||||||
|
virtual void run() = 0;
|
||||||
|
virtual QStringList sources() const = 0;
|
||||||
|
// used by extensions
|
||||||
|
int index(const QString source) const
|
||||||
|
{
|
||||||
|
QRegExp rx(QString("\\d+"));
|
||||||
|
rx.indexIn(source);
|
||||||
|
return rx.cap().toInt();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ABSTRACTEXTSYSMONSOURCE_H */
|
138
sources/extsysmon/sources/batterysource.cpp
Normal file
138
sources/extsysmon/sources/batterysource.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "batterysource.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
BatterySource::BatterySource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 1);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_acpiPath = args.at(0);
|
||||||
|
m_sources = getSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BatterySource::~BatterySource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant BatterySource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("battery/ac")) run();
|
||||||
|
return values[source];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap BatterySource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("battery/ac")) {
|
||||||
|
data[QString("min")] = false;
|
||||||
|
data[QString("max")] = true;
|
||||||
|
data[QString("name")] = QString("Is AC online or not");
|
||||||
|
data[QString("type")] = QString("bool");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("battery/bat")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 100;
|
||||||
|
data[QString("name")] = QString("Average battery usage");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("%");
|
||||||
|
} else {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 100;
|
||||||
|
data[QString("name")] = QString("Battery %1 usage").arg(source.remove(QString("battery/bat")));
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("%");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BatterySource::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
// adaptor
|
||||||
|
QFile acFile(QString("%1/AC/online").arg(m_acpiPath));
|
||||||
|
if (acFile.open(QIODevice::ReadOnly))
|
||||||
|
values[QString("battery/ac")] = (QString(acFile.readLine()).trimmed().toInt() == 1);
|
||||||
|
acFile.close();
|
||||||
|
|
||||||
|
// batterites
|
||||||
|
float currentLevel = 0.0;
|
||||||
|
float fullLevel = 0.0;
|
||||||
|
for (int i=0; i<m_batteriesCount; i++) {
|
||||||
|
QFile currentLevelFile(QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i));
|
||||||
|
QFile fullLevelFile(QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i));
|
||||||
|
if ((currentLevelFile.open(QIODevice::ReadOnly)) &&
|
||||||
|
(fullLevelFile.open(QIODevice::ReadOnly))) {
|
||||||
|
float batCurrent = QString(currentLevelFile.readLine()).trimmed().toFloat();
|
||||||
|
float batFull = QString(fullLevelFile.readLine()).trimmed().toFloat();
|
||||||
|
values[QString("battery/bat%1").arg(i)] = static_cast<int>(100 * batCurrent / batFull);
|
||||||
|
currentLevel += batCurrent;
|
||||||
|
fullLevel += batFull;
|
||||||
|
}
|
||||||
|
currentLevelFile.close();
|
||||||
|
fullLevelFile.close();
|
||||||
|
}
|
||||||
|
values[QString("battery/bat")] = static_cast<int>(100 * currentLevel / fullLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList BatterySource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList BatterySource::getSources()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("battery/ac"));
|
||||||
|
sources.append(QString("battery/bat"));
|
||||||
|
m_batteriesCount = QDir(m_acpiPath).entryList(QStringList() << QString("BAT*"),
|
||||||
|
QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name).count();
|
||||||
|
qCInfo(LOG_ESM) << "Init batteries count as" << m_batteriesCount;
|
||||||
|
for (int i=0; i<m_batteriesCount; i++)
|
||||||
|
sources.append(QString("battery/bat%1").arg(i));
|
||||||
|
|
||||||
|
qCInfo(LOG_ESM) << "Sources list" << sources;
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
46
sources/extsysmon/sources/batterysource.h
Normal file
46
sources/extsysmon/sources/batterysource.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef BATTERYSOURCE_H
|
||||||
|
#define BATTERYSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BatterySource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit BatterySource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~BatterySource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run();
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList getSources();
|
||||||
|
// configuration and values
|
||||||
|
int m_batteriesCount = 0;
|
||||||
|
QString m_acpiPath;
|
||||||
|
QStringList m_sources;
|
||||||
|
QVariantHash values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* BATTERYSOURCE_H */
|
87
sources/extsysmon/sources/customsource.cpp
Normal file
87
sources/extsysmon/sources/customsource.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "customsource.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "extscript.h"
|
||||||
|
|
||||||
|
|
||||||
|
CustomSource::CustomSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
|
||||||
|
m_sources = getSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CustomSource::~CustomSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
delete extScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant CustomSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
// there are only one value
|
||||||
|
return extScripts->itemByTagNumber(index(source))->run().values().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap CustomSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Custom command '%1' output").arg(extScripts->itemByTagNumber(index(source))->uniq());
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList CustomSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList CustomSource::getSources()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
foreach(ExtScript *item, extScripts->activeItems())
|
||||||
|
sources.append(QString("custom/%1").arg(item->tag(QString("custom"))));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
47
sources/extsysmon/sources/customsource.h
Normal file
47
sources/extsysmon/sources/customsource.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CUSTOMSOURCE_H
|
||||||
|
#define CUSTOMSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ExtScript;
|
||||||
|
|
||||||
|
class CustomSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CustomSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~CustomSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList getSources();
|
||||||
|
// configuration and values
|
||||||
|
ExtItemAggregator<ExtScript> *extScripts;
|
||||||
|
QStringList m_sources;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CUSTOMSOURCE_H */
|
112
sources/extsysmon/sources/desktopsource.cpp
Normal file
112
sources/extsysmon/sources/desktopsource.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "desktopsource.h"
|
||||||
|
|
||||||
|
#include <KWindowSystem>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
DesktopSource::DesktopSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DesktopSource::~DesktopSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant DesktopSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
int current = KWindowSystem::currentDesktop();
|
||||||
|
int total = KWindowSystem::numberOfDesktops();
|
||||||
|
|
||||||
|
if (source == QString("desktop/current/name")) {
|
||||||
|
return KWindowSystem::desktopName(current);
|
||||||
|
} else if (source == QString("desktop/current/number")) {
|
||||||
|
return current;
|
||||||
|
} else if (source == QString("desktop/total/name")) {
|
||||||
|
QStringList desktops;
|
||||||
|
for (int i=1; i<total+1; i++)
|
||||||
|
desktops.append(KWindowSystem::desktopName(i));
|
||||||
|
return desktops;
|
||||||
|
} else if (source == QString("desktop/total/number")) {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap DesktopSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("desktop/current/name")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current desktop name");
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("desktop/current/number")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Current desktop number");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("desktop/total/name")) {
|
||||||
|
data[QString("min")] = QStringList();
|
||||||
|
data[QString("max")] = QStringList();
|
||||||
|
data[QString("name")] = QString("All desktops by name");
|
||||||
|
data[QString("type")] = QString("QStringList");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("desktop/total/number")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Desktops count");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList DesktopSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("desktop/current/name"));
|
||||||
|
sources.append(QString("desktop/current/number"));
|
||||||
|
sources.append(QString("desktop/total/name"));
|
||||||
|
sources.append(QString("desktop/total/number"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
38
sources/extsysmon/sources/desktopsource.h
Normal file
38
sources/extsysmon/sources/desktopsource.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DESKTOPSOURCE_H
|
||||||
|
#define DESKTOPSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class DesktopSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DesktopSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~DesktopSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DESKTOPSOURCE_H */
|
111
sources/extsysmon/sources/gpuloadsource.cpp
Normal file
111
sources/extsysmon/sources/gpuloadsource.cpp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "gpuloadsource.h"
|
||||||
|
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
GPULoadSource::GPULoadSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 1);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_device = args.at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GPULoadSource::~GPULoadSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant GPULoadSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("gpu/load")) {
|
||||||
|
float value = 0.0;
|
||||||
|
if ((m_device != QString("nvidia")) && (m_device != QString("ati")))
|
||||||
|
return value;
|
||||||
|
// build cmd
|
||||||
|
QString cmd = m_device == QString("nvidia") ? QString("nvidia-smi -q -x") : QString("aticonfig --od-getclocks");
|
||||||
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
|
TaskResult process = runTask(cmd);
|
||||||
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
// parse
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
|
if (m_device == QString("nvidia"))
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (!str.contains(QString("<gpu_util>"))) continue;
|
||||||
|
QString load = str.remove(QString("<gpu_util>")).remove(QString("</gpu_util>"))
|
||||||
|
.remove(QChar('%'));
|
||||||
|
value = load.toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (m_device == QString("ati"))
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (!str.contains(QString("load"))) continue;
|
||||||
|
QString load = str.split(QChar(' '), QString::SkipEmptyParts)[3]
|
||||||
|
.remove(QChar('%'));
|
||||||
|
value = load.toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// return
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap GPULoadSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("gpu/load")) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 100.0;
|
||||||
|
data[QString("name")] = QString("GPU usage");
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("%");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList GPULoadSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("gpu/load"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
42
sources/extsysmon/sources/gpuloadsource.h
Normal file
42
sources/extsysmon/sources/gpuloadsource.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GPULOADSOURCE_H
|
||||||
|
#define GPULOADSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class GPULoadSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit GPULoadSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~GPULoadSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// configuration and values
|
||||||
|
QString m_device;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* GPULOADSOURCE_H */
|
109
sources/extsysmon/sources/gputempsource.cpp
Normal file
109
sources/extsysmon/sources/gputempsource.cpp
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "gputempsource.h"
|
||||||
|
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
GPUTemperatureSource::GPUTemperatureSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 1);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_device = args.at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GPUTemperatureSource::~GPUTemperatureSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant GPUTemperatureSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("gpu/temperature")) {
|
||||||
|
float value = 0.0;
|
||||||
|
if ((m_device != QString("nvidia")) && (m_device != QString("ati")))
|
||||||
|
return value;
|
||||||
|
// build cmd
|
||||||
|
QString cmd = m_device == QString("nvidia") ? QString("nvidia-smi -q -x") : QString("aticonfig --od-gettemperature");
|
||||||
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
|
TaskResult process = runTask(cmd);
|
||||||
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
// parse
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
|
if (m_device == QString("nvidia"))
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (!str.contains(QString("<gpu_temp>"))) continue;
|
||||||
|
QString temp = str.remove(QString("<gpu_temp>")).remove(QString("C</gpu_temp>"));
|
||||||
|
value = temp.toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (m_device == QString("ati"))
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (!str.contains(QString("Temperature"))) continue;
|
||||||
|
QString temp = str.split(QChar(' '), QString::SkipEmptyParts).at(4);
|
||||||
|
value = temp.toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// return
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap GPUTemperatureSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("gpu/temperature")) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("GPU temperature");
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("°C");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList GPUTemperatureSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("gpu/temperature"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
42
sources/extsysmon/sources/gputempsource.h
Normal file
42
sources/extsysmon/sources/gputempsource.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GPUTEMPSOURCE_H
|
||||||
|
#define GPUTEMPSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class GPUTemperatureSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit GPUTemperatureSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~GPUTemperatureSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// configuration and values
|
||||||
|
QString m_device;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* GPUTEMPSOURCE_H */
|
107
sources/extsysmon/sources/hddtempsource.cpp
Normal file
107
sources/extsysmon/sources/hddtempsource.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "hddtempsource.h"
|
||||||
|
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
HDDTemperatureSource::HDDTemperatureSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 2);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_devices = args.at(0).split(QChar(','));
|
||||||
|
m_cmd = args.at(1);
|
||||||
|
|
||||||
|
m_smartctl = m_cmd.contains(QString("smartctl"));
|
||||||
|
qCInfo(LOG_ESM) << "Parse as smartctl" << m_smartctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HDDTemperatureSource::~HDDTemperatureSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant HDDTemperatureSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QString device = source.remove(QString("hdd/temperature"));
|
||||||
|
float value = 0.0;
|
||||||
|
// run cmd
|
||||||
|
TaskResult process = runTask(QString("%1 %2").arg(m_cmd).arg(device));
|
||||||
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
|
// parse
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
|
if (m_smartctl) {
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (!str.startsWith(QString("194"))) continue;
|
||||||
|
if (str.split(QChar(' '), QString::SkipEmptyParts).count() < 9) break;
|
||||||
|
value = str.split(QChar(' '), QString::SkipEmptyParts).at(9).toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||||
|
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts).at(2);
|
||||||
|
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||||
|
value = temp.toFloat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap HDDTemperatureSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QString device = source.remove(QString("hdd/temperature"));
|
||||||
|
QVariantMap data;
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("HDD '%1' temperature").arg(device);
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("°C");
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList HDDTemperatureSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
foreach(QString device, m_devices)
|
||||||
|
sources.append(QString("hdd/temperature%1").arg(device));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
44
sources/extsysmon/sources/hddtempsource.h
Normal file
44
sources/extsysmon/sources/hddtempsource.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef HDDTEMPSOURCE_H
|
||||||
|
#define HDDTEMPSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class HDDTemperatureSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit HDDTemperatureSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~HDDTemperatureSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// configuration and values
|
||||||
|
QString m_cmd;
|
||||||
|
QStringList m_devices;
|
||||||
|
bool m_smartctl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* HDDTEMPSOURCE_H */
|
89
sources/extsysmon/sources/networksource.cpp
Normal file
89
sources/extsysmon/sources/networksource.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "networksource.h"
|
||||||
|
|
||||||
|
#include <QNetworkInterface>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
NetworkSource::NetworkSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NetworkSource::~NetworkSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant NetworkSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("network/current/name")) {
|
||||||
|
QString device = QString("lo");
|
||||||
|
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||||
|
qCInfo(LOG_ESM) << "Devices" << rawInterfaceList;
|
||||||
|
foreach(QNetworkInterface interface, rawInterfaceList)
|
||||||
|
if ((interface.flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||||
|
(!interface.flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||||
|
(!interface.flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||||
|
device = interface.name();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap NetworkSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("network/current/name")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current network device name");
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList NetworkSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("network/current/name"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
38
sources/extsysmon/sources/networksource.h
Normal file
38
sources/extsysmon/sources/networksource.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef NETWORKSOURCE_H
|
||||||
|
#define NETWORKSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit NetworkSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~NetworkSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* NETWORKSOURCE_H */
|
334
sources/extsysmon/sources/playersource.cpp
Normal file
334
sources/extsysmon/sources/playersource.cpp
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "playersource.h"
|
||||||
|
|
||||||
|
#include <QDBusArgument>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusConnectionInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
PlayerSource::PlayerSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 5);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
m_player = args.at(0);
|
||||||
|
m_mpdAddress = QString("%1:%2").arg(args.at(1)).arg(args.at(2));
|
||||||
|
m_mpris = args.at(3);
|
||||||
|
m_symbols = args.at(4).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlayerSource::~PlayerSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant PlayerSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("player/title")) run();
|
||||||
|
return values[source];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap PlayerSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("player/album")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song album");
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/salbum")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song album (%1 symbols)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/dalbum")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song album (%1 symbols, dynamic)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/artist")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song artist");
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/sartist")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song artist (%1 symbols)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/dartist")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song artist (%1 symbols, dynamic)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/duration")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Current song duration");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("s");
|
||||||
|
} else if (source == QString("player/progress")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Current song progress");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("s");
|
||||||
|
} else if (source == QString("player/title")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song title");
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/stitle")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song title (%1 symbols)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("player/dtitle")) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Current song title (%1 symbols, dynamic)").arg(m_symbols);
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PlayerSource::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
// initial data
|
||||||
|
if (m_player == QString("mpd")) {
|
||||||
|
// mpd
|
||||||
|
values = getPlayerMpdInfo(m_mpdAddress);
|
||||||
|
} else if (m_player == QString("mpris")) {
|
||||||
|
// players which supports mpris
|
||||||
|
QString mpris = m_mpris == QString("auto") ? getAutoMpris() : m_mpris;
|
||||||
|
if (mpris.isEmpty()) return;
|
||||||
|
values = getPlayerMprisInfo(mpris);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dymanic properties
|
||||||
|
// solid
|
||||||
|
values[QString("player/salbum")] = stripString(values[QString("player/album")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
values[QString("player/sartist")] = stripString(values[QString("player/artist")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
values[QString("player/stitle")] = stripString(values[QString("player/title")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
// dynamic
|
||||||
|
values[QString("player/dalbum")] = buildString(values[QString("player/dalbum")].toString(),
|
||||||
|
values[QString("player/album")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
values[QString("player/dartist")] = buildString(values[QString("player/dartist")].toString(),
|
||||||
|
values[QString("player/artist")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
values[QString("player/dtitle")] = buildString(values[QString("player/dtitle")].toString(),
|
||||||
|
values[QString("player/title")].toString(),
|
||||||
|
m_symbols);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList PlayerSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("player/album"));
|
||||||
|
sources.append(QString("player/dalbum"));
|
||||||
|
sources.append(QString("player/salbum"));
|
||||||
|
sources.append(QString("player/artist"));
|
||||||
|
sources.append(QString("player/dartist"));
|
||||||
|
sources.append(QString("player/sartist"));
|
||||||
|
sources.append(QString("player/duration"));
|
||||||
|
sources.append(QString("player/progress"));
|
||||||
|
sources.append(QString("player/title"));
|
||||||
|
sources.append(QString("player/dtitle"));
|
||||||
|
sources.append(QString("player/stitle"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString PlayerSource::getAutoMpris() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, QString("ListNames"));
|
||||||
|
if (listServices.arguments().isEmpty()) return QString();
|
||||||
|
QStringList arguments = listServices.arguments().first().toStringList();
|
||||||
|
|
||||||
|
foreach(QString arg, arguments) {
|
||||||
|
if (!arg.startsWith(QString("org.mpris.MediaPlayer2."))) continue;
|
||||||
|
qCInfo(LOG_ESM) << "Service found" << arg;
|
||||||
|
QString service = arg;
|
||||||
|
service.remove(QString("org.mpris.MediaPlayer2."));
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash PlayerSource::getPlayerMpdInfo(const QString mpdAddress) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "MPD" << mpdAddress;
|
||||||
|
|
||||||
|
QVariantHash info;
|
||||||
|
info[QString("player/album")] = QString("unknown");
|
||||||
|
info[QString("player/artist")] = QString("unknown");
|
||||||
|
info[QString("player/duration")] = 0;
|
||||||
|
info[QString("player/progress")] = 0;
|
||||||
|
info[QString("player/title")] = QString("unknown");
|
||||||
|
|
||||||
|
// build cmd
|
||||||
|
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1\"")
|
||||||
|
.arg(mpdAddress);
|
||||||
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
|
TaskResult process = runTask(cmd);
|
||||||
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
|
if (str.split(QString(": "), QString::SkipEmptyParts).count() == 1) {
|
||||||
|
// "Metadata: data"
|
||||||
|
QString metadata = str.split(QString(": "), QString::SkipEmptyParts).first().toLower();
|
||||||
|
QString data = str.split(QString(": "), QString::SkipEmptyParts).last().trimmed();
|
||||||
|
if (metadata == QString("time")) {
|
||||||
|
QStringList times = data.split(QString(":"));
|
||||||
|
info[QString("player/duration")] = times.at(0).toInt();
|
||||||
|
info[QString("player/progress")] = times.at(1).toInt();
|
||||||
|
} else if (metadata == QString("Title")) {
|
||||||
|
info[QString("player/%1").arg(metadata)] = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash PlayerSource::getPlayerMprisInfo(const QString mpris) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "MPRIS" << mpris;
|
||||||
|
|
||||||
|
QVariantHash info;
|
||||||
|
info[QString("player/album")] = QString("unknown");
|
||||||
|
info[QString("player/artist")] = QString("unknown");
|
||||||
|
info[QString("player/duration")] = 0;
|
||||||
|
info[QString("player/progress")] = 0;
|
||||||
|
info[QString("player/title")] = QString("unknown");
|
||||||
|
|
||||||
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
|
// comes from the following request:
|
||||||
|
// qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata
|
||||||
|
// or the same but using dbus-send:
|
||||||
|
// dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'
|
||||||
|
QVariantList args = QVariantList() << QString("org.mpris.MediaPlayer2.Player") << QString("Metadata");
|
||||||
|
QDBusMessage request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
|
||||||
|
QString("/org/mpris/MediaPlayer2"),
|
||||||
|
QString(""),
|
||||||
|
QString("Get"));
|
||||||
|
request.setArguments(args);
|
||||||
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
|
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
||||||
|
qCWarning(LOG_ESM) << "Error message" << response.errorMessage();
|
||||||
|
} else {
|
||||||
|
// another portion of dirty magic
|
||||||
|
QVariantHash map = qdbus_cast<QVariantHash>(response.arguments().first()
|
||||||
|
.value<QDBusVariant>().variant()
|
||||||
|
.value<QDBusArgument>());
|
||||||
|
info[QString("player/album")] = map.value(QString("xesam:album"), QString("unknown"));
|
||||||
|
// artist is array
|
||||||
|
info[QString("player/artist")] = map.value(QString("xesam:artist"), QString("unknown")).toString();
|
||||||
|
info[QString("player/duration")] = map.value(QString("mpris:length"), 0).toInt() / (1000 * 1000);
|
||||||
|
info[QString("player/title")] = map.value(QString("xesam:title"), QString("unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// position
|
||||||
|
args[1] = QString("Position");
|
||||||
|
request.setArguments(args);
|
||||||
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
|
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
||||||
|
qCWarning(LOG_ESM) << "Error message" << response.errorMessage();
|
||||||
|
} else {
|
||||||
|
// this cast is simpler than the previous one ;)
|
||||||
|
info[QString("player/progress")] = response.arguments().first().value<QDBusVariant>()
|
||||||
|
.variant().toLongLong() / (1000 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString PlayerSource::buildString(const QString current, const QString value,
|
||||||
|
const int s) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Current value" << current;
|
||||||
|
qCDebug(LOG_ESM) << "New value" << value;
|
||||||
|
qCDebug(LOG_ESM) << "Strip after" << s;
|
||||||
|
|
||||||
|
int index = value.indexOf(current);
|
||||||
|
if ((current.isEmpty()) || ((index + s + 1) > value.count()))
|
||||||
|
return value.leftJustified(s, QLatin1Char(' '));
|
||||||
|
else
|
||||||
|
return QString("%1").arg(value.mid(index + 1, s), s, QLatin1Char(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString PlayerSource::stripString(const QString value, const int s) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "New value" << value;
|
||||||
|
qCDebug(LOG_ESM) << "Strip after" << s;
|
||||||
|
|
||||||
|
return value.count() > s ? QString("%1\u2026").arg(value.left(s - 1)) :
|
||||||
|
value.leftJustified(s, QLatin1Char(' '));
|
||||||
|
}
|
52
sources/extsysmon/sources/playersource.h
Normal file
52
sources/extsysmon/sources/playersource.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PLAYERSOURCE_H
|
||||||
|
#define PLAYERSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class PlayerSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PlayerSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~PlayerSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run();
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString getAutoMpris() const;
|
||||||
|
QVariantHash getPlayerMpdInfo(const QString mpdAddress) const;
|
||||||
|
QVariantHash getPlayerMprisInfo(const QString mpris) const;
|
||||||
|
// additional method to build dynamic tags
|
||||||
|
QString buildString(const QString current, const QString value, const int s) const;
|
||||||
|
QString stripString(const QString value, const int s) const;
|
||||||
|
// configuration and values
|
||||||
|
QString m_mpdAddress;
|
||||||
|
QString m_mpris;
|
||||||
|
QString m_player;
|
||||||
|
int m_symbols;
|
||||||
|
QVariantHash values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PLAYERSOURCE_H */
|
115
sources/extsysmon/sources/processessource.cpp
Normal file
115
sources/extsysmon/sources/processessource.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "processessource.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
ProcessesSource::ProcessesSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ProcessesSource::~ProcessesSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant ProcessesSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source == QString("ps/running/count")) run();
|
||||||
|
return values[source];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap ProcessesSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("ps/running/count")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Count of running processes");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("ps/running/list")) {
|
||||||
|
data[QString("min")] = QStringList();
|
||||||
|
data[QString("max")] = QStringList();
|
||||||
|
data[QString("name")] = QString("All running processes list");
|
||||||
|
data[QString("type")] = QString("QStringList");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source == QString("ps/total/count")) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Total count of processes");
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProcessesSource::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||||
|
QDir::Name);
|
||||||
|
QStringList directories = allDirectories.filter(QRegExp(QString("(\\d+)")));
|
||||||
|
QStringList running;
|
||||||
|
|
||||||
|
foreach(QString dir, directories) {
|
||||||
|
QFile statusFile(QString("/proc/%1/status").arg(dir));
|
||||||
|
if (!statusFile.open(QIODevice::ReadOnly)) continue;
|
||||||
|
QFile cmdFile(QString("/proc/%1/cmdline").arg(dir));
|
||||||
|
if (!cmdFile.open(QIODevice::ReadOnly)) continue;
|
||||||
|
|
||||||
|
QString output = statusFile.readAll();
|
||||||
|
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
values[QString("ps/running/count")] = running.count();
|
||||||
|
values[QString("ps/running/list")] = running;
|
||||||
|
values[QString("ps/total/count")] = directories.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList ProcessesSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("ps/running/count"));
|
||||||
|
sources.append(QString("ps/running/list"));
|
||||||
|
sources.append(QString("ps/total/count"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
42
sources/extsysmon/sources/processessource.h
Normal file
42
sources/extsysmon/sources/processessource.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PROCESSESSOURCE_H
|
||||||
|
#define PROCESSESSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessesSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ProcessesSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~ProcessesSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run();
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// configuration and values
|
||||||
|
QVariantHash values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PROCESSESSOURCE_H */
|
149
sources/extsysmon/sources/quotessource.cpp
Normal file
149
sources/extsysmon/sources/quotessource.cpp
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "quotessource.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "extquotes.h"
|
||||||
|
|
||||||
|
|
||||||
|
QuotesSource::QuotesSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
|
||||||
|
m_sources = getSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QuotesSource::~QuotesSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
delete extQuotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant QuotesSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source.startsWith(QString("quotes/percpricechg")))
|
||||||
|
values[source] = extQuotes->itemByTagNumber(index(source))->run();
|
||||||
|
QString base = QString(source).remove(QString("quotes/"));
|
||||||
|
return values[source][base];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap QuotesSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
int ind = index(source);
|
||||||
|
QVariantMap data;
|
||||||
|
if (source.startsWith(QString("quotes/askchg"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Absolute ask changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/ask"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Ask for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/percaskchg"))) {
|
||||||
|
data[QString("min")] = -100.0;
|
||||||
|
data[QString("max")] = 100.0;
|
||||||
|
data[QString("name")] = QString("Ask changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/bidchg"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Absolute bid changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/bid"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Bid for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/percbidchg"))) {
|
||||||
|
data[QString("min")] = -100.0;
|
||||||
|
data[QString("max")] = 100.0;
|
||||||
|
data[QString("name")] = QString("Bid changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/pricechg"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Absolute prie changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/price"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Price for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("quotes/percpricechg"))) {
|
||||||
|
data[QString("min")] = -100.0;
|
||||||
|
data[QString("max")] = 100.0;
|
||||||
|
data[QString("name")] = QString("Price changes for '%1'").arg(extQuotes->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList QuotesSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList QuotesSource::getSources()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
foreach(ExtQuotes *item, extQuotes->activeItems()) {
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("ask"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("askchg"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("percaskchg"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("bid"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("bidchg"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("percbidchg"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("price"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("pricechg"))));
|
||||||
|
sources.append(QString("quotes/%1").arg(item->tag(QString("percpricechg"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
48
sources/extsysmon/sources/quotessource.h
Normal file
48
sources/extsysmon/sources/quotessource.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QUOTESSOURCE_H
|
||||||
|
#define QUOTESSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ExtQuotes;
|
||||||
|
|
||||||
|
class QuotesSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit QuotesSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~QuotesSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList getSources();
|
||||||
|
// configuration and values
|
||||||
|
ExtItemAggregator<ExtQuotes> *extQuotes;
|
||||||
|
QStringList m_sources;
|
||||||
|
QHash<QString, QVariantHash> values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* QUOTESSOURCE_H */
|
73
sources/extsysmon/sources/updatesource.cpp
Normal file
73
sources/extsysmon/sources/updatesource.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "updatesource.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
UpdateSource::UpdateSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpdateSource::~UpdateSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant UpdateSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap UpdateSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
if (source == QString("desktop/current/name")) {
|
||||||
|
data[QString("min")] = true;
|
||||||
|
data[QString("max")] = true;
|
||||||
|
data[QString("name")] = QString("Simple value which is always true");
|
||||||
|
data[QString("type")] = QString("bool");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList UpdateSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
sources.append(QString("update"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
38
sources/extsysmon/sources/updatesource.h
Normal file
38
sources/extsysmon/sources/updatesource.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UPDATESOURCE_H
|
||||||
|
#define UPDATESOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UpdateSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~UpdateSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* UPDATESOURCE_H */
|
87
sources/extsysmon/sources/upgradesource.cpp
Normal file
87
sources/extsysmon/sources/upgradesource.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "upgradesource.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "extupgrade.h"
|
||||||
|
|
||||||
|
|
||||||
|
UpgradeSource::UpgradeSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
|
||||||
|
m_sources = getSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpgradeSource::~UpgradeSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
delete extUpgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant UpgradeSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
// there are only one value
|
||||||
|
return extUpgrade->itemByTagNumber(index(source))->run().values().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap UpgradeSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
QVariantMap data;
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("Package manager '%1' metadata").arg(extUpgrade->itemByTagNumber(index(source))->uniq());
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList UpgradeSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList UpgradeSource::getSources()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
foreach(ExtUpgrade *item, extUpgrade->activeItems())
|
||||||
|
sources.append(QString("upgrade/%1").arg(item->tag(QString("pkgcount"))));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
47
sources/extsysmon/sources/upgradesource.h
Normal file
47
sources/extsysmon/sources/upgradesource.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UPGRADESOURCE_H
|
||||||
|
#define UPGRADESOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ExtUpgrade;
|
||||||
|
|
||||||
|
class UpgradeSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UpgradeSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~UpgradeSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList getSources();
|
||||||
|
// configuration and values
|
||||||
|
ExtItemAggregator<ExtUpgrade> *extUpgrade;
|
||||||
|
QStringList m_sources;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* UPGRADESOURCE_H */
|
121
sources/extsysmon/sources/weathersource.cpp
Normal file
121
sources/extsysmon/sources/weathersource.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "weathersource.h"
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "extweather.h"
|
||||||
|
|
||||||
|
|
||||||
|
WeatherSource::WeatherSource(QObject *parent, const QStringList args)
|
||||||
|
: AbstractExtSysMonSource(parent, args)
|
||||||
|
{
|
||||||
|
Q_ASSERT(args.count() == 0);
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
|
||||||
|
m_sources = getSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WeatherSource::~WeatherSource()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
delete extWeather;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant WeatherSource::data(QString source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
if (source.startsWith(QString("weather/weatherId")))
|
||||||
|
values[source] = extWeather->itemByTagNumber(index(source))->run();
|
||||||
|
QString base = QString(source).remove(QString("weather/"));
|
||||||
|
return values[source][base];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantMap WeatherSource::initialData(QString source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Source" << source;
|
||||||
|
|
||||||
|
int ind = index(source);
|
||||||
|
QVariantMap data;
|
||||||
|
if (source.startsWith(QString("weather/weatherId"))) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 1000;
|
||||||
|
data[QString("name")] = QString("Numeric weather ID for '%1'").arg(extWeather->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("weather/weather"))) {
|
||||||
|
data[QString("min")] = QString("");
|
||||||
|
data[QString("max")] = QString("");
|
||||||
|
data[QString("name")] = QString("ID string map for '%1'").arg(extWeather->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("QString");
|
||||||
|
data[QString("units")] = QString("");
|
||||||
|
} else if (source.startsWith(QString("weather/humidity"))) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 100;
|
||||||
|
data[QString("name")] = QString("Humidity for '%1'").arg(extWeather->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("%");
|
||||||
|
} else if (source.startsWith(QString("weather/humidity"))) {
|
||||||
|
data[QString("min")] = 0;
|
||||||
|
data[QString("max")] = 0;
|
||||||
|
data[QString("name")] = QString("Atmospheric pressure for '%1'").arg(extWeather->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("integer");
|
||||||
|
data[QString("units")] = QString("hPa");
|
||||||
|
} else if (source.startsWith(QString("weather/temperature"))) {
|
||||||
|
data[QString("min")] = 0.0;
|
||||||
|
data[QString("max")] = 0.0;
|
||||||
|
data[QString("name")] = QString("Temperature for '%1'").arg(extWeather->itemByTagNumber(ind)->uniq());
|
||||||
|
data[QString("type")] = QString("float");
|
||||||
|
data[QString("units")] = QString("°C");
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList WeatherSource::sources() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
return m_sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList WeatherSource::getSources()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
foreach(ExtWeather *item, extWeather->activeItems()) {
|
||||||
|
sources.append(QString("weather/%1").arg(item->tag(QString("weatherId"))));
|
||||||
|
sources.append(QString("weather/%1").arg(item->tag(QString("weather"))));
|
||||||
|
sources.append(QString("weather/%1").arg(item->tag(QString("humidity"))));
|
||||||
|
sources.append(QString("weather/%1").arg(item->tag(QString("pressure"))));
|
||||||
|
sources.append(QString("weather/%1").arg(item->tag(QString("temperature"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
48
sources/extsysmon/sources/weathersource.h
Normal file
48
sources/extsysmon/sources/weathersource.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef WEATHERSOURCE_H
|
||||||
|
#define WEATHERSOURCE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "abstractextsysmonsource.h"
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ExtWeather;
|
||||||
|
|
||||||
|
class WeatherSource : public AbstractExtSysMonSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit WeatherSource(QObject *parent, const QStringList args);
|
||||||
|
virtual ~WeatherSource();
|
||||||
|
QVariant data(QString source);
|
||||||
|
QVariantMap initialData(QString source) const;
|
||||||
|
void run() {};
|
||||||
|
QStringList sources() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList getSources();
|
||||||
|
// configuration and values
|
||||||
|
ExtItemAggregator<ExtWeather> *extWeather;
|
||||||
|
QStringList m_sources;
|
||||||
|
QHash<QString, QVariantHash> values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* WEATHERSOURCE_H */
|
Loading…
Reference in New Issue
Block a user