mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
implement #51 for upgrade and scripts
This commit is contained in:
parent
396fa95ec3
commit
b82d78bcbe
@ -21,7 +21,7 @@ rm -rf "${ARCHIVE}"
|
||||
# build widget
|
||||
ARCHIVE="awesome-widgets"
|
||||
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
|
||||
IGNORELIST="build usr .kdev4 sources.kdev4"
|
||||
IGNORELIST="build usr .kdev4 *.kdev4"
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
|
23
sources/.kdev4/awesomewidgets.kdev4
Normal file
23
sources/.kdev4/awesomewidgets.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||
Build Type=Debug
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
@ -26,19 +26,16 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
# task source is required by extscripts
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../../extsysmon/extquotes.cpp
|
||||
../../extsysmon/extscript.cpp
|
||||
../../extsysmon/extupgrade.cpp)
|
||||
set (SUBPROJECT_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
set (SUBPROJECT_DESKTOP ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||
|
||||
qt5_wrap_cpp (SUBPROJECT_MOC_SOURCE ${SUBPROJECT_HEADER})
|
||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${SUBPROJECT_MOC_SOURCE})
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/awesomewidget)
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
@ -39,6 +38,11 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringLis
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
// init process
|
||||
process = new QProcess(this);
|
||||
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
process->waitForFinished(0);
|
||||
// init ui
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
@ -47,6 +51,8 @@ ExtScript::~ExtScript()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
process->kill();
|
||||
delete process;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -318,36 +324,14 @@ QString ExtScript::run()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return value;
|
||||
|
||||
if (times == 1) {
|
||||
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||
QStringList cmdList;
|
||||
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
|
||||
cmdList.append(m_executable);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
|
||||
TaskResult process = runTask(cmdList.join(QChar(' ')));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString info = QString("%1 : %2").arg(process.exitCode)
|
||||
.arg(QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed());
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
switch (m_redirect) {
|
||||
case stdout2stderr:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||
break;
|
||||
case stderr2stdout:
|
||||
value = QString("%1\t%2").arg(info).arg(qoutput);
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
||||
value = qoutput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// update value
|
||||
if (times >= m_interval) times = 0;
|
||||
process->start(cmdList.join(QChar(' ')));
|
||||
} else if (times >= m_interval)
|
||||
times = 0;
|
||||
times++;
|
||||
|
||||
return value;
|
||||
@ -424,3 +408,29 @@ void ExtScript::writeConfiguration()
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::updateValue()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
|
||||
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << qdebug;
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||
|
||||
switch (m_redirect) {
|
||||
case stdout2stderr:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||
break;
|
||||
case stderr2stdout:
|
||||
value = QString("%1\t%2").arg(qdebug).arg(qoutput);
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
|
||||
value = qoutput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define EXTSCRIPT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
@ -83,10 +84,14 @@ public slots:
|
||||
bool tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtScript *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
@ -99,6 +104,7 @@ private:
|
||||
bool m_output = true;
|
||||
QString m_prefix = QString("");
|
||||
Redirect m_redirect = nothing;
|
||||
Q_PID childProcess = 0;
|
||||
int times = 0;
|
||||
QString value = QString();
|
||||
};
|
||||
|
@ -69,6 +69,16 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
||||
}
|
||||
|
||||
|
||||
ExtendedSysMon::~ExtendedSysMon()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
externalQuotes.clear();
|
||||
externalScripts.clear();
|
||||
externalUpgrade.clear();
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAllHdd()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -408,9 +418,8 @@ float ExtendedSysMon::getGpu(const QString device)
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-getclocks");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
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();
|
||||
@ -452,9 +461,8 @@ float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-gettemperature");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
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);
|
||||
@ -487,9 +495,8 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
|
||||
|
||||
float value = 0.0;
|
||||
TaskResult process = runTask(cmd + QString(" ") + device);
|
||||
TaskResult process = runTask(QString("%1 %2").arg(cmd).arg(device));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
bool smartctl = cmd.contains(QString("smartctl"));
|
||||
@ -583,7 +590,6 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddres
|
||||
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();
|
||||
@ -661,7 +667,8 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDir::Name);
|
||||
QStringList directories = allDirectories.filter(QRegExp(QString("(\\d+)")));
|
||||
QStringList running;
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
class ExtQuotes;
|
||||
@ -31,7 +30,8 @@ class ExtendedSysMon : public Plasma::DataEngine
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
explicit ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
~ExtendedSysMon();
|
||||
// update functions
|
||||
QMap<QString, QVariant> getBattery(const QString acpiPath);
|
||||
QMap<QString, QVariant> getCurrentDesktop();
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
@ -39,6 +38,11 @@ ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, const QString
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
// init process
|
||||
process = new QProcess(this);
|
||||
connect(process, SIGNAL(finished(int)), this, SLOT(updateValue()));
|
||||
process->waitForFinished(0);
|
||||
// init ui
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
@ -47,6 +51,8 @@ ExtUpgrade::~ExtUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
process->kill();
|
||||
delete process;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -244,18 +250,10 @@ int ExtUpgrade::run()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return value;
|
||||
|
||||
if (times == 1) {
|
||||
TaskResult process = runTask(QString("bash -c \"%1\"").arg(m_executable));
|
||||
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();
|
||||
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
|
||||
}
|
||||
|
||||
// update value
|
||||
if (times >= m_interval) times = 0;
|
||||
if ((times == 1) && (process->state() == QProcess::NotRunning))
|
||||
process->start(QString("bash -c \"%1\"").arg(m_executable));
|
||||
else if (times >= m_interval)
|
||||
times = 0;
|
||||
times++;
|
||||
|
||||
return value;
|
||||
@ -326,3 +324,15 @@ void ExtUpgrade::writeConfiguration()
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::updateValue()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process->readAllStandardError();
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define EXTUPGRADE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
@ -69,10 +70,14 @@ public slots:
|
||||
bool tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtUpgrade *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user