diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..2c18cc7 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,46 @@ +# Author: Evgeniy "arcanis" Alexeev +# Maintainer: Evgeniy "arcanis" Alexeev + +pkgname=kdeplasma-applets-pytextmonitor +_pkgname=py-text-monitor +pkgver=1.3.4 +pkgrel=1 +_dtengine=ext-sysmon +_dtver=1.1 +pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm" +arch=(any) +url="https://github.com/arcan1s/pytextmonitor" +license=('GPL') +depends=('kdebindings-python2' 'lm_sensors' 'net-tools') +optdepends=('catalyst: for GPU monitor' + 'nvidia-utils: for GPU monitor') +makedepends=('unzip') +source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.1.3.4/${_pkgname}-${pkgver}.plasmoid + https://github.com/arcan1s/pytextmonitor/releases/download/V.1.3.4/${_dtengine}-${_dtver}.zip) +md5sums=('cdc55960177a07b52ab0a2713f5df212' + '84fde352850f4d46309e5077a7db22a6') + +build () +{ +# build dataengine + unzip -o -q ${srcdir}/${_dtengine}-${_dtver}.zip -d ${srcdir}/${_dtengine} + if [ -d ${srcdir}/${_dtengine}/build ]; then + rm -r build + fi + mkdir ${srcdir}/${_dtengine}/build && cd ${srcdir}/${_dtengine}/build + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../ + make +} + +package() +{ +# install dataengine + cd ${srcdir}/${_dtengine}/build + make DESTDIR=${pkgdir} install + +# install plasmoid + unzip -o -q ${srcdir}/${_pkgname}-${pkgver}.plasmoid -d ${srcdir}/${_pkgname} + install -D ${srcdir}/${_pkgname}/metadata.desktop ${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop + mkdir -p ${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname} + cp -r ${srcdir}/${_pkgname}/* ${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/ +} \ No newline at end of file diff --git a/ext-sysmon-1.1.zip b/ext-sysmon-1.1.zip new file mode 100644 index 0000000..2ca4f1b Binary files /dev/null and b/ext-sysmon-1.1.zip differ diff --git a/ext-sysmon/CMakeLists.txt b/ext-sysmon/CMakeLists.txt new file mode 100644 index 0000000..437f774 --- /dev/null +++ b/ext-sysmon/CMakeLists.txt @@ -0,0 +1,25 @@ +project (extsysmon) + +# Find the required Libaries +find_package (KDE4 REQUIRED) +include (KDE4Defaults) + +add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) +include_directories (${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${KDE4_INCLUDES}) + +set (CMAKE_CXX_FLAGS "-fexceptions") +set (extsysmon_engine_SRCS extsysmon.cpp) + +# Now make sure all files get to the right place +kde4_add_plugin (plasma_engine_extsysmon ${extsysmon_engine_SRCS}) +target_link_libraries(plasma_engine_extsysmon + ${KDE4_KDECORE_LIBS} + ${KDE4_PLASMA_LIBS}) + +install(TARGETS plasma_engine_extsysmon + DESTINATION ${PLUGIN_INSTALL_DIR}) + +install(FILES plasma-engine-extsysmon.desktop + DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/ext-sysmon/CMakeLists.txt.user b/ext-sysmon/CMakeLists.txt.user new file mode 100644 index 0000000..aa23587 --- /dev/null +++ b/ext-sysmon/CMakeLists.txt.user @@ -0,0 +1,182 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {a22d6db7-e0a5-452b-9173-b8efacd95ba3} + 0 + 0 + 0 + + /home/arcanis/Documents/github/pytextmonitor/ext-sysmon-build + false + + + + + all + + false + false + true + Сборка + + CMakeProjectManager.MakeStep + + 1 + Сборка + + ProjectExplorer.BuildSteps.Build + + + + clean + + true + false + true + Сборка + + CMakeProjectManager.MakeStep + + 1 + Очистка + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + all + + CMakeProjectManager.CMakeBuildConfiguration + + 1 + + + 0 + Установка + + ProjectExplorer.BuildSteps.Deploy + + 1 + Локальная установка + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + true + + false + false + false + false + true + 0.01 + 10 + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + + false + %{buildDir} + Запуск std::exception &E + + ProjectExplorer.CustomExecutableRunConfiguration + 3768 + true + false + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {ab3ec085-9c1a-4bfc-af86-f7898da68a64} + + + ProjectExplorer.Project.Updater.FileVersion + 14 + + diff --git a/ext-sysmon/contents/code/main.py b/ext-sysmon/contents/code/main.py deleted file mode 100644 index 7ca3cea..0000000 --- a/ext-sysmon/contents/code/main.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- - -from PyQt4.QtCore import * -from PyKDE4.kdecore import * -from PyKDE4 import plasmascript -import commands - - - -class ExtendedSysMon(plasmascript.DataEngine): - def __init__(self, parent, args=None): - """dataengine definition""" - plasmascript.DataEngine.__init__(self, parent) - - - def init(self): - """initialization""" - self.setMinimumPollingInterval(333) - - # setup gpu device - self.gpudev = '' - commandOut = commands.getoutput("lspci") - if (commandOut.lower().find('nvidia') > -1): - self.gpudev = 'nvidia' - elif (commandOut.lower().find('radeon') > -1): - self.gpudev = 'ati' - - # setup hdd devices - self.hdddev = [] - commandOut = commands.getoutput("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z]") - for device in commandOut.split('\n'): - if (device[:3] != "ls:"): - self.hdddev.append(device) - - - def sources(self): - """create sources""" - sources = ["gpu", "gputemp", "hddtemp"] - return sources - - - def sourceRequestEvent(self, name): - return self.updateSourceEvent(name) - - - def updateSourceEvent(self, source): - """update sources and setup values""" - if (source == "gpu"): - key = "GPU" - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1") - try: - value = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1))) - except: - value = " N\A" - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1") - try: - value = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1))) - except: - value = " N\A" - else: - value = " N\A" - self.setData(source, "GPU", QString(value)) - elif (source == "gputemp"): - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1") - try: - value = "%4s" % (str(round(float(commandOut.split()[2]), 1))) - except: - value = " N\A" - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1") - try: - value = "%4s" % (str(round(float(commandOut.split()[4]), 1))) - except: - value = " N\A" - else: - value = " N\A" - self.setData(source, "GPUTemp", QString(value)) - elif (source == "hddtemp"): - for device in self.hdddev: - commandOut = commands.getoutput("hddtemp " + device) - try: - value = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1))) - except: - value = " N\A" - self.setData(source, device, QString(value)) - - return True - - - -def CreateDataEngine(parent): - return ExtendedSysMon(parent) diff --git a/ext-sysmon/extsysmon.cpp b/ext-sysmon/extsysmon.cpp new file mode 100644 index 0000000..e1f25c6 --- /dev/null +++ b/ext-sysmon/extsysmon.cpp @@ -0,0 +1,188 @@ +#include "extsysmon.h" +#include +#include + +ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args) + : Plasma::DataEngine(parent, args) +{ + Q_UNUSED(args) + + setMinimumPollingInterval(333); + + FILE *f_out; + f_out = popen("lspci 2>&1", "r"); + char device[256]; + QString dev; + while (fgets(device, 256, f_out) != NULL) + { + dev = QString(device); + if (dev.toLower().contains("nvidia")) + gpudev = QString("nvidia"); + else if (dev.toLower().contains("radeon")) + gpudev = QString("ati"); + } + pclose(f_out); + + f_out = popen("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z] 2>&1", "r"); + while (fgets(device, 256, f_out) != NULL) + { + dev = QString(device); + if (dev[0] == '/') + hdddev.append(dev); + } + pclose(f_out); +} + +QStringList ExtendedSysMon::sources() const +{ + QStringList source; + source.append(QString("gpu")); + source.append(QString("gputemp")); + source.append(QString("hddtemp")); + return source; +} + +bool ExtendedSysMon::sourceRequestEvent(const QString &name) +{ + return updateSourceEvent(name); +} + +bool ExtendedSysMon::updateSourceEvent(const QString &source) +{ + QLocale::setDefault(QLocale::C); + + FILE *f_out; + QString key, out, tmp_out, value; + bool ok = false; + char output[256], val[5]; + if (source == QString("gpu")) + { + key = QString("GPU"); + if (gpudev == QString("nvidia")) + { + try + { + f_out = popen("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1 2>&1", "r"); + fgets (output, 256, f_out); + if (output[0] == '\0') + throw; + out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2]; + sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok)); + value = QString(val); + pclose(f_out); + } + catch(std::exception &e) + { + value = QString(" N\\A"); + } + } + else if (gpudev == QString("ati")) + { + try + { + f_out = popen("aticonfig --od-getclocks | grep load | tail -n1 2>&1", "r"); + fgets (output, 256, f_out); + if (output[0] == '\0') + throw; + printf ("lol?"); + out = QString(output).split(QString(" "), QString::SkipEmptyParts)[3]; + sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok)); + value = QString(val); + pclose(f_out); + } + catch(std::exception &e) + { + value = QString(" N\\A"); + } + } + else + { + value = QString(" N\\A"); + } + if (ok == false) + value = QString(" N\\A"); + setData(source, key, value); + } + else if (source == QString("gputemp")) + { + key = QString("GPUTemp"); + if (gpudev == QString("nvidia")) + { + try + { + f_out = popen("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1 2>&1", "r"); + fgets (output, 256, f_out); + if (output[0] == '\0') + throw; + out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2]; + sprintf (val, "%4.1f", out.toFloat(&ok)); + value = QString(val); + pclose(f_out); + } + catch(std::exception &e) + { + value = QString(" N\\A"); + } + } + else if (gpudev == QString("ati")) + { + try + { + f_out = popen("aticonfig --od-gettemperature | grep Temperature | tail -n1 2>&1", "r"); + fgets (output, 256, f_out); + if (output[0] == '\0') + throw; + out = QString(output).split(QString(" "), QString::SkipEmptyParts)[4]; + sprintf (val, "%4.1f", out.toFloat(&ok)); + value = QString(val); + } + catch(std::exception &e) + { + value = QString(" N\\A"); + } + pclose(f_out); + } + else + { + value = QString(" N\\A"); + } + if (ok == false) + value = QString(" N\\A"); + setData(source, key, value); + } + else if (source == QString("hddtemp")) + { + char command[256], *dev; + QByteArray qb; + for (int i=0; i&1", dev); + try + { + f_out = popen(command, "r"); + fgets(output, 256, f_out); + if (output[0] == '\0') + throw; + out = QString(output).split(QString(":"), QString::SkipEmptyParts)[2]; + sprintf (val, "%4.1f", out.left(out.count()-4).toFloat(&ok)); + value = QString(val); + pclose(f_out); + } + catch(std::exception &e) + { + value = QString(" N\\A"); + } + if (ok == false) + value = QString(" N\\A"); + setData(source, hdddev[i], value); + } + } + + return true; +} + +K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon) + +#include "extsysmon.moc" diff --git a/ext-sysmon/extsysmon.h b/ext-sysmon/extsysmon.h new file mode 100644 index 0000000..5a38081 --- /dev/null +++ b/ext-sysmon/extsysmon.h @@ -0,0 +1,21 @@ +#ifndef EXTSYSMON_H +#define EXTSYSMON_H + +#include + +class ExtendedSysMon : public Plasma::DataEngine +{ + Q_OBJECT + +public: + ExtendedSysMon(QObject *parent, const QVariantList &args); + +protected: + bool sourceRequestEvent(const QString &name); + bool updateSourceEvent(const QString &source); + QStringList hdddev; + QString gpudev; + QStringList sources() const; +}; + +#endif // EXTSYSMON_H diff --git a/ext-sysmon/metadata.desktop b/ext-sysmon/plasma-engine-extsysmon.desktop similarity index 77% rename from ext-sysmon/metadata.desktop rename to ext-sysmon/plasma-engine-extsysmon.desktop index fbb6af4..c57609e 100644 --- a/ext-sysmon/metadata.desktop +++ b/ext-sysmon/plasma-engine-extsysmon.desktop @@ -6,14 +6,13 @@ ServiceTypes=Plasma/DataEngine Type=Service Icon=utilities-system-monitor -X-Plasma-API=python -X-Plasma-MainScript=code/main.py - +X-KDE-ServiceTypes=Plasma/DataEngine +X-KDE-Library=plasma_engine_extsysmon +X-Plasma-EngineName=ext-sysmon X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=ext-sysmon -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website=http://kde-look.org/ +X-KDE-PluginInfo-Version=1.1 X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL diff --git a/ext-sysmon-1.0.zip b/old_versions/ext-sysmon-1.0.zip similarity index 100% rename from ext-sysmon-1.0.zip rename to old_versions/ext-sysmon-1.0.zip