mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
Start rebuild dataengine from Python to CPP
This commit is contained in:
parent
76ffab569e
commit
669571e803
46
PKGBUILD
Normal file
46
PKGBUILD
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Author: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
||||||
|
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
||||||
|
|
||||||
|
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}/
|
||||||
|
}
|
BIN
ext-sysmon-1.1.zip
Normal file
BIN
ext-sysmon-1.1.zip
Normal file
Binary file not shown.
25
ext-sysmon/CMakeLists.txt
Normal file
25
ext-sysmon/CMakeLists.txt
Normal file
@ -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})
|
182
ext-sysmon/CMakeLists.txt.user
Normal file
182
ext-sysmon/CMakeLists.txt.user
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 2.8.0, 2013-08-26T03:37:39. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QString" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap"/>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{a22d6db7-e0a5-452b-9173-b8efacd95ba3}</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory">/home/arcanis/Documents/github/pytextmonitor/ext-sysmon-build</value>
|
||||||
|
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString">all</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.UseNinja">false</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.UseNinja">false</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">all</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Установка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Локальная установка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||||
|
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||||
|
<value type="int">0</value>
|
||||||
|
<value type="int">1</value>
|
||||||
|
<value type="int">2</value>
|
||||||
|
<value type="int">3</value>
|
||||||
|
<value type="int">4</value>
|
||||||
|
<value type="int">5</value>
|
||||||
|
<value type="int">6</value>
|
||||||
|
<value type="int">7</value>
|
||||||
|
<value type="int">8</value>
|
||||||
|
<value type="int">9</value>
|
||||||
|
<value type="int">10</value>
|
||||||
|
<value type="int">11</value>
|
||||||
|
<value type="int">12</value>
|
||||||
|
<value type="int">13</value>
|
||||||
|
<value type="int">14</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||||
|
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Запуск std::exception &E</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||||
|
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="int">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{ab3ec085-9c1a-4bfc-af86-f7898da68a64}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">14</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
@ -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)
|
|
188
ext-sysmon/extsysmon.cpp
Normal file
188
ext-sysmon/extsysmon.cpp
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
#include "extsysmon.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Plasma/DataContainer>
|
||||||
|
|
||||||
|
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<hdddev.count(); i++)
|
||||||
|
{
|
||||||
|
qb = hdddev[i].toUtf8();
|
||||||
|
dev = qb.data();
|
||||||
|
sprintf(command, "sudo hddtemp %s 2>&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"
|
21
ext-sysmon/extsysmon.h
Normal file
21
ext-sysmon/extsysmon.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef EXTSYSMON_H
|
||||||
|
#define EXTSYSMON_H
|
||||||
|
|
||||||
|
#include <Plasma/DataEngine>
|
||||||
|
|
||||||
|
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
|
@ -6,14 +6,13 @@ ServiceTypes=Plasma/DataEngine
|
|||||||
Type=Service
|
Type=Service
|
||||||
Icon=utilities-system-monitor
|
Icon=utilities-system-monitor
|
||||||
|
|
||||||
X-Plasma-API=python
|
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||||
X-Plasma-MainScript=code/main.py
|
X-KDE-Library=plasma_engine_extsysmon
|
||||||
|
X-Plasma-EngineName=ext-sysmon
|
||||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=ext-sysmon
|
X-KDE-PluginInfo-Name=ext-sysmon
|
||||||
X-KDE-PluginInfo-Version=1.0
|
X-KDE-PluginInfo-Version=1.1
|
||||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
|
||||||
X-KDE-PluginInfo-Category=System Information
|
X-KDE-PluginInfo-Category=System Information
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
X-KDE-PluginInfo-License=GPL
|
X-KDE-PluginInfo-License=GPL
|
Loading…
Reference in New Issue
Block a user