mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-10 04:15:51 +00:00
move back desktop files
add widget configuration append plugin slots rewrite KF5 and DE to use ExtUpgrade class some fixes
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_engine_extsysmon)
|
||||
set (SUBPROJECT plasma_dataengine_extsysmon)
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
@ -42,6 +42,7 @@ set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
set (SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
|
||||
set (SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
@ -69,3 +70,4 @@ endif ()
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
install (DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||
install (DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||
|
@ -29,12 +29,12 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd) :
|
||||
QDialog(parent),
|
||||
m_fileName(scriptName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtScript)
|
||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(scriptName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtScript)
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
@ -292,6 +292,8 @@ ExtScript::ScriptData ExtScript::run(const int time)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
|
||||
TaskResult process = runTask(cmdList.join(QChar(' ')));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString info = QString::number(process.exitCode) + QString(":") +
|
||||
QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed();
|
||||
|
@ -30,10 +30,12 @@
|
||||
#include <QTextCodec>
|
||||
#include <QSettings>
|
||||
|
||||
#include <extscript.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
#include <version.h>
|
||||
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "version.h"
|
||||
|
||||
// KF5-KDE4 compability
|
||||
#ifdef BUILD_KDE4
|
||||
@ -57,6 +59,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
initScripts();
|
||||
initUpgrade();
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +104,9 @@ QString ExtendedSysMon::getAutoMpris()
|
||||
QString cmd = QString("bash -c \"qdbus 'org.mpris.MediaPlayer2.*'\"");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
if (qoutput.split(QChar('\n'))[0].split(QChar('.')).count() > 3)
|
||||
@ -119,20 +125,61 @@ void ExtendedSysMon::initScripts()
|
||||
QString localDir;
|
||||
QStringList dirs;
|
||||
#ifdef BUILD_KDE4
|
||||
localDir = KStandardDirs::locateLocal("data", "plasma_engine_extsysmon/scripts");
|
||||
localDir = KStandardDirs::locateLocal("data", "plasma_dataengine_extsysmon/scripts");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = KGlobal::dirs()->findDirs("data", "plasma_engine_extsysmon/scripts");
|
||||
dirs = KGlobal::dirs()->findDirs("data", "plasma_dataengine_extsysmon/scripts");
|
||||
#else
|
||||
localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_engine_extsysmon/scripts");
|
||||
QString("/plasma_dataengine_extsysmon/scripts");
|
||||
QDir localDirectory;
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
QString("plasma_engine_extsysmon/scripts"),
|
||||
QString("plasma_dataengine_extsysmon/scripts"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
times.clear();
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
externalScripts.append(new ExtScript(0, files[j], dirs, debug));
|
||||
times.append(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::initUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// create directory at $HOME and create dirs list
|
||||
QString localDir;
|
||||
QStringList dirs;
|
||||
#ifdef BUILD_KDE4
|
||||
localDir = KStandardDirs::locateLocal("data", "plasma_dataengine_extsysmon/upgrade");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = KGlobal::dirs()->findDirs("data", "plasma_dataengine_extsysmon/upgrade");
|
||||
#else
|
||||
localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_dataengine_extsysmon/upgrade");
|
||||
QDir localDirectory;
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
QString("plasma_dataengine_extsysmon/upgrade"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
@ -144,8 +191,7 @@ void ExtendedSysMon::initScripts()
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
externalScripts.append(new ExtScript(0, files[j], dirs, debug));
|
||||
times.append(1);
|
||||
externalUpgrade.append(new ExtUpgrade(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,8 +241,6 @@ void ExtendedSysMon::readConfiguration()
|
||||
rawConfig[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost")).toString();
|
||||
rawConfig[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600")).toString();
|
||||
rawConfig[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto")).toString();
|
||||
rawConfig[QString("PKGCMD")] = settings.value(QString("PKGCMD"), QString("pacman -Qu")).toString();
|
||||
rawConfig[QString("PKGNULL")] = settings.value(QString("PKGNULL"), QString("0")).toString();
|
||||
rawConfig[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
@ -234,11 +278,6 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
|
||||
else
|
||||
rawConfig[QString("HDDDEV")] = devices.join(QChar(','));
|
||||
}
|
||||
// pkgcmd
|
||||
for (int i=rawConfig[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts).count();
|
||||
i<rawConfig[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count();
|
||||
i++)
|
||||
rawConfig[QString("PKGNULL")] += QString(",0");
|
||||
// player
|
||||
if ((rawConfig[QString("PLAYER")] != QString("mpd")) &&
|
||||
(rawConfig[QString("PLAYER")] != QString("mpris")))
|
||||
@ -327,6 +366,8 @@ float ExtendedSysMon::getGpu(const QString device)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||
@ -369,6 +410,8 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||
@ -402,6 +445,8 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
||||
float value = 0.0;
|
||||
TaskResult process = runTask(cmd + QString(" ") + device);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||
@ -465,6 +510,8 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
QString qstr = QString("");
|
||||
@ -515,6 +562,8 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
QStringList psList;
|
||||
@ -528,6 +577,8 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
psStats[QString("pstotal")] = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
||||
@ -536,20 +587,6 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
}
|
||||
|
||||
|
||||
int ExtendedSysMon::getUpgradeInfo(const QString cmd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
|
||||
return qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::sourceRequestEvent(const QString &source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -586,9 +623,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<desktop.keys().count(); i++)
|
||||
setData(source, desktop.keys()[i], desktop[desktop.keys()[i]]);
|
||||
} else if (source == QString("gpu")) {
|
||||
setData(source, QString("GPU"), getGpu(configuration[QString("GPUDEV")]));
|
||||
setData(source, QString("value"), getGpu(configuration[QString("GPUDEV")]));
|
||||
} else if (source == QString("gputemp")) {
|
||||
setData(source, QString("GPUTemp"), getGpuTemp(configuration[QString("GPUDEV")]));
|
||||
setData(source, QString("value"), getGpuTemp(configuration[QString("GPUDEV")]));
|
||||
} else if (source == QString("hddtemp")) {
|
||||
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
@ -598,9 +635,8 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
setData(source, QString("value"), getNetworkDevice());
|
||||
} else if (source == QString("pkg")) {
|
||||
if (pkgTimeUpdate > MSEC_IN_HOUR) {
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i),
|
||||
getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i]));
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run());
|
||||
pkgTimeUpdate = 0;
|
||||
}
|
||||
pkgTimeUpdate++;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
|
||||
class ExtendedSysMon : public Plasma::DataEngine
|
||||
{
|
||||
@ -46,7 +47,6 @@ public:
|
||||
const QString mpdPort = 0,
|
||||
QString mpris = 0);
|
||||
QMap<QString, QVariant> getPsStats();
|
||||
int getUpgradeInfo(const QString cmd);
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &source);
|
||||
@ -57,6 +57,7 @@ private:
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QList<ExtScript *> externalScripts;
|
||||
QList<ExtUpgrade *> externalUpgrade;
|
||||
QList<int> times;
|
||||
bool debug;
|
||||
// FIXME dirty hack to avoid update package information every second
|
||||
@ -66,6 +67,7 @@ private:
|
||||
QString getAutoGpu();
|
||||
QString getAutoMpris();
|
||||
void initScripts();
|
||||
void initUpgrade();
|
||||
void readConfiguration();
|
||||
QMap<QString, QString> updateConfiguration(QMap<QString, QString> rawConfig);
|
||||
};
|
||||
|
253
sources/extsysmon/extupgrade.cpp
Normal file
253
sources/extsysmon/extupgrade.cpp
Normal file
@ -0,0 +1,253 @@
|
||||
/***************************************************************************
|
||||
* 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 "extupgrade.h"
|
||||
#include "ui_extupgrade.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, const QStringList directories, const bool debugCmd) :
|
||||
QDialog(parent),
|
||||
m_fileName(upgradeName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtUpgrade)
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
ExtUpgrade::~ExtUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::executable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::null()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_null;
|
||||
}
|
||||
|
||||
|
||||
bool ExtUpgrade::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setActive(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
m_active = state;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setExecutable(const QString _executable)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setNull(const int _null)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
|
||||
if (_null < 0) return;
|
||||
|
||||
m_null = _null;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
TaskResult process = runTask(QString("bash -c \"") + m_executable + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
|
||||
return (qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null);
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::showConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_null->setValue(m_null);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWEUAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setNull(ui->spinBox_null->value());
|
||||
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("Exec"), m_executable);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Null"), m_null);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
80
sources/extsysmon/extupgrade.h
Normal file
80
sources/extsysmon/extupgrade.h
Normal file
@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* 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 EXTUPGRADE_H
|
||||
#define EXTUPGRADE_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ExtUpgrade;
|
||||
}
|
||||
|
||||
class ExtUpgrade : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(int null READ null WRITE setNull)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
|
||||
public:
|
||||
explicit ExtUpgrade(QWidget *parent = 0, const QString upgradeName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtUpgrade();
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
QString name();
|
||||
int null();
|
||||
bool isActive();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNull(const int _null = 0);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int run();
|
||||
void showConfiguration();
|
||||
void tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::ExtUpgrade *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QString m_name = QString("none");
|
||||
int m_null = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTUPGRADE_H */
|
200
sources/extsysmon/extupgrade.ui
Normal file
200
sources/extsysmon/extupgrade.ui
Normal file
@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExtUpgrade</class>
|
||||
<widget class="QDialog" name="ExtUpgrade">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_comment">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_comment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_command">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_command"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_active">
|
||||
<item>
|
||||
<spacer name="spacer_active">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_active">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_null">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_null">
|
||||
<property name="text">
|
||||
<string>Null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_null">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ExtUpgrade</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ExtUpgrade</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -14,17 +14,5 @@ MPDPORT=6600
|
||||
# MPRIS player name or 'auto'. In the most cases it should be a player name
|
||||
## DBus path is org.mpris.MediaPlayer2.amarok
|
||||
MPRIS=auto
|
||||
# Package upgrade info
|
||||
## from vicious
|
||||
## Arch: PKGCMD=pacman -Qu PKGNULL=0
|
||||
## Debian: PKGCMD=apt-show-versions -u -b PKGNULL=0
|
||||
## Ubuntu: PKGCMD=aptitude search '~U' PKGNULL=0
|
||||
## Fedora: PKGCMD=yum list updates PKGNULL=3
|
||||
## FreeBSD: PKGCMD=pkg_version -I -l '<' PKGNULL=0
|
||||
## Mandriva: PKGCMD=urpmq --auto-select PKGNULL=0
|
||||
## Commands to run, comma separated
|
||||
PKGCMD=pacman -Qu
|
||||
## Number of null lines for commands, comma separated
|
||||
PKGNULL=0
|
||||
# Player name. Supported players are 'mpd', 'mpris'
|
||||
PLAYER=mpris
|
||||
|
@ -7,7 +7,7 @@ Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_extsysmon
|
||||
X-KDE-Library=plasma_dataengine_extsysmon
|
||||
X-Plasma-EngineName=extsysmon
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
|
@ -8,3 +8,4 @@ X-AW-Active=true
|
||||
X-AW-Output=true
|
||||
X-AW-Redirect=nothing
|
||||
X-AW-Interval=1
|
||||
X-AW-ApiVersion=1
|
||||
|
@ -16,3 +16,5 @@ X-AW-Output=false
|
||||
X-AW-Redirect=nothing
|
||||
# update interval in default AW intervals
|
||||
X-AW-Interval=1
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
||||
|
9
sources/extsysmon/upgrade/default-arch.desktop
Normal file
9
sources/extsysmon/upgrade/default-arch.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-arch
|
||||
Comment=Archlinux upgrade info
|
||||
Exec=pacman -Qu
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-ApiVersion=1
|
9
sources/extsysmon/upgrade/default-debian.desktop
Normal file
9
sources/extsysmon/upgrade/default-debian.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-debian
|
||||
Comment=Debian upgrade info
|
||||
Exec=apt-show-versions -u -b
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-ApiVersion=1
|
9
sources/extsysmon/upgrade/default-fedora.desktop
Normal file
9
sources/extsysmon/upgrade/default-fedora.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-fedora
|
||||
Comment=Fedora upgrade info
|
||||
Exec=yum list updates
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=3
|
||||
X-AW-ApiVersion=1
|
9
sources/extsysmon/upgrade/default-mandriva.desktop
Normal file
9
sources/extsysmon/upgrade/default-mandriva.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-mandriva
|
||||
Comment=Mandriva upgrade info
|
||||
Exec=urpmq --auto-select
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-ApiVersion=1
|
9
sources/extsysmon/upgrade/default-ubuntu.desktop
Normal file
9
sources/extsysmon/upgrade/default-ubuntu.desktop
Normal file
@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-ubuntu
|
||||
Comment=Ubuntu upgrade info
|
||||
Exec=aptitude search '~U'
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-ApiVersion=1
|
Reference in New Issue
Block a user