From 4c59e7e8922436f7fdbf69e49a3a359871670c44 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 24 May 2013 19:48:10 +0400 Subject: [PATCH] New release 1.3.2: * optimization and refactoring * gpu* and hddtemp now read from ext-sysmon DataEngine Extended SystemMonitor DataEngine: initial release 1.0: + add gpu source + add gputemp source + add hddtemp source + add install script --- README | 1 + extsysmon-1.0.zip | Bin 0 -> 1831 bytes extsysmon/contents/code/main.py | 95 ++++++ extsysmon/metadata.desktop | 20 ++ install_extsysmon.sh | 3 + .../pytextmonitor-1.3.1-unstable.plasmoid | Bin pytextmonitor-1.3.2.plasmoid | Bin 0 -> 15432 bytes source/contents/code/config.py | 2 +- .../code/{configaccepted.py => configdef.py} | 112 +++++-- source/contents/code/configwindow.py | 2 +- source/contents/code/dataengine.py | 314 ++++++++++-------- source/contents/code/gpuchecker.py | 38 --- source/contents/code/gputempchecker.py | 35 -- source/contents/code/hddtempchecker.py | 29 -- source/contents/code/main.py | 119 ++----- source/contents/code/reinit.py | 72 ++-- source/contents/code/util.py | 12 +- source/metadata.desktop | 8 +- 18 files changed, 447 insertions(+), 415 deletions(-) create mode 100644 extsysmon-1.0.zip create mode 100644 extsysmon/contents/code/main.py create mode 100644 extsysmon/metadata.desktop create mode 100755 install_extsysmon.sh rename pytextmonitor-1.3.1-unstable.plasmoid => old_versions/pytextmonitor-1.3.1-unstable.plasmoid (100%) create mode 100644 pytextmonitor-1.3.2.plasmoid rename source/contents/code/{configaccepted.py => configdef.py} (54%) delete mode 100644 source/contents/code/gpuchecker.py delete mode 100644 source/contents/code/gputempchecker.py delete mode 100644 source/contents/code/hddtempchecker.py diff --git a/README b/README index 0ec3a52..feb15de 100644 --- a/README +++ b/README @@ -26,3 +26,4 @@ For edited output you must open Settings window and setup output format in lines Label order will changed if you change slider position. HTML tags in label work normally. Attention: you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label. +Attention: gpu, gputemp and hddtemp labels require extsysmon dataengine! diff --git a/extsysmon-1.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fh%k5J@j=?SMQt{e`Is+Q?{@F1%AfyUjWXW>wp;(gwZl*?!>!UhYfgI-+vaVYf!!U?%071YfidF zT64XvOL%jr_v#guX}xQw{CfLbrMY*h`LRj+l4T?3tNxhQlPWriJKnQ(>qIW;f4i!E z@+XTgYz$9lnxb&itb%E;*@_buVO&C@W?YJq5^EVd#e=G@-T0Sfp_Db#;bdP>U%64e zX>@^l=wZEx4>gxL*Sr2(Zu8_P|74x)<~{0HHG>`m+yCZoto- z%eu~&%Iul(;CEWb=36f;t^TRb$=tBsz5RcKc|qJ!$NWvND?iG9ixd2yJaO;o&tXot zBrm5OGyORyj-%<=jswf5Zd81^MWJ+MKBw8c>z^xAMeXHnKP*4{>d*^~Z?Y%a0}eTU zku5B;Rke3G{mr^u^Yoocp*>NXw3A8Y_u*51D4bYG!;wA4De=U1G -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/extsysmon/metadata.desktop b/extsysmon/metadata.desktop new file mode 100644 index 0000000..fbb6af4 --- /dev/null +++ b/extsysmon/metadata.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Extended SystemMonitor DataEngine +Comment=Adds gpu, gputemp and hddtemp to DataEngine +ServiceTypes=Plasma/DataEngine +Type=Service +Icon=utilities-system-monitor + +X-Plasma-API=python +X-Plasma-MainScript=code/main.py + +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-Category=System Information +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true diff --git a/install_extsysmon.sh b/install_extsysmon.sh new file mode 100755 index 0000000..f336a9a --- /dev/null +++ b/install_extsysmon.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +plasmapkg -t dataengine -i extsysmon-1.0.zip diff --git a/pytextmonitor-1.3.1-unstable.plasmoid b/old_versions/pytextmonitor-1.3.1-unstable.plasmoid similarity index 100% rename from pytextmonitor-1.3.1-unstable.plasmoid rename to old_versions/pytextmonitor-1.3.1-unstable.plasmoid diff --git a/pytextmonitor-1.3.2.plasmoid b/pytextmonitor-1.3.2.plasmoid new file mode 100644 index 0000000000000000000000000000000000000000..cb115354f8d9f4459ed467265b4946e1c5e0737f GIT binary patch literal 15432 zcmaKz19YUzw#Q@JwkCEawr$&tz0qq5X!w|9xoZ+M3RJjcA^eRZ}-7?6OS#-*=2mB-V^( z3f0RpGR=3*@lEyRtSSI@yn}bu4+rtZy<2pxcKLSSV=-zfI$}CKp8dN{q9zkVGOJG! zEp*{THsQe`RykOLJDPFaQ`S2@*q-cMb6-f%ICceQk@HUq4}Q#ITkuBrZ}zbsNhtfW zdfE$zgPMrp>B4}aH^Yrel2Rnvn-8j6{S>XHC zvXRi@nAI>KVK^*m`4*dTRmh5(UENd2NZn|l0T$!TE_5SKyh#ytLrC^Bazat0C_3b3 zt6kmTJ?0VXz9?uAkuPr3I#@ypY7D@4K3fRZE+my7IU%Rcs4whFE?iy-01_pS2%ju3 z4BDH10<#>!gmXq{2J{y@Q^G8C8Q`dIcO}s}%ExL$cxckvTE<)+ zlg;D%+yNe!F_Aeq3L{Fq!w>$5jhCQ0YWeK(DTv;9jG=+ZM&D{d5GeK#2VKIbg0`D)KHicgS3zv`!zxr`TcA>#{p-pNShB2ve1o~zx z4g`aMMES8UaAM01MwS?kM+|bSe$^pN^9KQf1i{#+GL1j%qIm71ps@l>17ZFBYpiZO zIE@s%kxu}Mfm;bho$+Ob(pY4hJYOJ~84F{g zIS8Bp0?tzRv;l@sfroEZu-2GB5*JxVv0+zpejsH=mlLWx_ugKxzeRfQ&%0qxwbPns zCgV>W?fpzX3K1N>i#_MNk5z)70ndlua?Nn)aPGQ)>AFu01XO}A)+sPwRqU{nRFcg` zR$$3Lu}R)om*vF;oG!a(*!qEc(_TikA5=yqb3}cz3d0_M_47(iKXZY<)LRL#ywXzT z5l>B9Rt=Zy34H7VVa#R@tIqF`mB83}^dfS<`=`hR7;}|os_7PaKNGX~!wB9-n7{W^ zK`_1%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y%gVN6iQ^F5J7U`<7@Q&=8`gZDyV8-~-K@Qd(TX!#3|fnzP%VYioSe z^N@04ftZ(!6A<|18d3$&3!Kv#?a#eIC@L0mWYdu85wnu5>ob^((6p77I*c36ce55} zgtEl1-|Comd`(fK2(24QG4u%2&aE_8!eZ!DmM*pc>IQs;J6$lxAjg-c)4gg6(?>yK_ZDu!(n1bqn|pjowa^8a!*MAO0*V6VXz+y| zO-D`?ZB(0ki0qU{Y4pOGpEc8lm)aewNfSqjoe?_UZe?;t+GtaO8Z4WdtH<;5;NgCh z>KupOHrHDYwNj1RjqQcu9ikj>zsv8h#Rf)xm56V*-RN1YPKcNXestU@P{0`*S>9ri zcDPr_>YsmZrc zV|lF3b}%aHRcdIGG5nB zd%$@%?0{ZcAmLmJo1=6@qY^0EofpHu{@CS5KQlOsq=yCMpC{{ZKmY&;pS!%Zv7`QP zxg)KSv4f?f?YDoZ9c99@ax&39HO(JF))VrN28K=2F*=-1qBhc}+tM@LNv zwemaqb*)KJD>bWdLL3oL$i`d36i-S@ky##~(3|VpaTI65UZ#Lcha_M{y@BKWjAojU zl#@+Q>SdrIZeTVaX49J%#-VL-lz5egdIKe;T{!tD1 zN&H>7_iu^+sTS~`#LrsS&)yr0Z}tKa=? z)&Hd6{bSJiKEZ!u{zcFG*}-o;?|-q%-(^OBbWrajg!{H zO^p6m^q&MTpYY#;m;VC)yL{x&aFWkA|989n!`T0CK7WfzKD+oWCiyR2{QVgDk1q0k zygm<>|9=<%cc}b{{(Y$YU(kQgF#mzB_xVZkSM;Cq&7bh!`R4xu|9gn@2Rz>=jrOnb zf12iB0naD@cfj*s_ 0)): - time.sleep(self.interval) - # dirty hack - self.label_exit = self.label_exit - 1 - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1") - if (commandOut.split()[2] == 'N/A'): - self.gpu = ' N/A' - else: - self.gpu = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1))) - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1") - self.gpu = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1))) - else: - self.gpu = '-----' - - - def stop(self): - """stop signal""" - self.stopped = True diff --git a/source/contents/code/gputempchecker.py b/source/contents/code/gputempchecker.py deleted file mode 100644 index 65c2533..0000000 --- a/source/contents/code/gputempchecker.py +++ /dev/null @@ -1,35 +0,0 @@ -import commands, time, os -from PyQt4.QtCore import QThread - - - -class GpuTempThread(QThread): - def __init__(self, interval, gpudev): - """thread definition""" - QThread.__init__(self) - self.stopped = False - self.interval = interval / 1000 - self.label_exit = 2 - self.gpudev = gpudev - self.gputemp = '----' - - - def run(self): - """operating function""" - while ((not self.stopped) and (self.label_exit > 0)): - time.sleep(self.interval) - # dirty hack - self.label_exit = self.label_exit - 1 - if (self.gpudev == 'nvidia'): - commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1") - self.gputemp = "%4s" % (str(round(float(commandOut.split()[2]), 1))) - elif (self.gpudev == 'ati'): - commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1") - self.gputemp = "%4s" % (str(round(float(commandOut.split()[4]), 1))) - else: - self.gputemp = '----' - - - def stop(self): - """stop signal""" - self.stopped = True diff --git a/source/contents/code/hddtempchecker.py b/source/contents/code/hddtempchecker.py deleted file mode 100644 index b1a0000..0000000 --- a/source/contents/code/hddtempchecker.py +++ /dev/null @@ -1,29 +0,0 @@ -import commands, time -from PyQt4.QtCore import QThread - - - -class HddTempThread(QThread): - def __init__(self, interval, hdd): - """thread definition""" - QThread.__init__(self) - self.stopped = False - self.interval = interval / 1000 - self.label_exit = 2 - self.hdd = hdd - self.hddtemp = '----' - - - def run(self): - """operating function""" - while ((not self.stopped) and (self.label_exit > 0)): - time.sleep(self.interval) - # dirty hack - self.label_exit = self.label_exit - 1 - commandOut = commands.getoutput("hddtemp " + self.hdd) - self.hddtemp = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1))) - - - def stop(self): - """stop signal""" - self.stopped = True diff --git a/source/contents/code/main.py b/source/contents/code/main.py index 80e6832..c9eb12f 100644 --- a/source/contents/code/main.py +++ b/source/contents/code/main.py @@ -9,7 +9,7 @@ from PyKDE4 import plasmascript from PyKDE4.plasma import Plasma import commands, os, time -import configaccepted +import configdef import configwindow import dataengine import reinit @@ -20,57 +20,42 @@ from util import * class pyTextWidget(plasmascript.Applet): def __init__(self, parent, args=None): """widget definition""" - plasmascript.Applet.__init__(self,parent) + plasmascript.Applet.__init__(self, parent) def init(self): """function to initializate widget""" self._name = str(self.package().metadata().pluginName()) + self.initTooltip() self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet) - self.configAccepted = configaccepted.ConfigAccepted(self) + self.dataengine = dataengine.DataEngine(self) self.reinit = reinit.Reinit(self) + + self.timer = QTimer() + QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel) + self.setupVar() self.reinit.reinit() + self.setHasConfigurationInterface(True) def createConfigurationInterface(self, parent): """function to setup configuration window""" - self.configpage = configwindow.ConfigWindow(self, self.settings) - - font = QFont(str(self.settings.get('font_family', 'Terminus')), int(self.settings.get('font_size', 12)), 50) - self.configpage.ui.spinBox_interval.setValue(int(self.settings.get('interval', 2000))) - self.configpage.ui.fontComboBox.setCurrentFont(font) - self.configpage.ui.spinBox_fontSize.setValue(int(self.settings.get('font_size', 12))) - self.configpage.ui.kcolorcombo.setColor(QColor(str(self.settings.get('font_color', '#000000')))) - font = str(self.settings.get('font_style', 'normal')) - if (font == 'normal'): - self.configpage.ui.comboBox_style.setCurrentIndex(0) - else: - self.configpage.ui.comboBox_style.setCurrentIndex(1) - self.configpage.ui.spinBox_weight.setValue(int(self.settings.get('font_weight', 400))) - for label in self.dict_orders.keys(): - exec ('bool = self.' + self.dict_orders[label] + 'Bool') - if (bool == 1): - self.configpage.checkboxes[self.dict_orders[label]].setCheckState(2) - self.configpage.sliders[self.dict_orders[label]].setValue(self.label_order.find(label)+1) - else: - self.configpage.checkboxes[self.dict_orders[label]].setCheckState(0) - if (self.dict_orders[label] == 'net'): - self.configpage.ui.comboBox_numNet.setCurrentIndex(int(self.settings.get('num_dev', 0))) - self.configpage.lineedits[self.dict_orders[label]].setText(str(self.settings.get(self.dict_orders[label] + 'NonFormat', self.dict_defFormat[self.dict_orders[label]]))) - else: - self.configpage.lineedits[self.dict_orders[label]].setText(str(self.settings.get(self.dict_orders[label] + 'Format', self.dict_defFormat[self.dict_orders[label]]))) - if (self.dict_orders[label] == 'bat'): - self.configpage.ui.lineEdit_batdev.setText(str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))) - self.configpage.ui.lineEdit_acdev.setText(str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online'))) - - # add config page - page = parent.addPage(self.configpage, i18n(self.name())) - page.setIcon(KIcon(self.icon())) - - parent.okClicked.connect(self.configAccepted.configAccepted) + self.configpage = configwindow.ConfigWindow(self) + self.configdef = configdef.ConfigDefinition(self, self.configpage) + self.configdef.createConfigurationInterface(parent) + + + def initTooltip(self): + """function to create tooltip""" + self.tooltip = Plasma.ToolTipContent() + self.tooltip.setMainText("PyTetMonitor") + self.tooltip.setSubText('') + Plasma.ToolTipManager.self().registerWidget(self.applet) + # show tooltip + #Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip) def setupNetdev(self): @@ -102,12 +87,6 @@ class pyTextWidget(plasmascript.Applet): # setup temperature device commandOut = commands.getoutput("sensors | grep Physical -B2") self.tempdev = "lmsensors/"+commandOut.split("\n")[0]+"/"+'_'.join(commandOut.split("\n")[2].split(":")[0].split()) - # setup gpu device - commandOut = commands.getoutput("lspci") - if (commandOut.lower().find('nvidia') > -1): - self.gpudev = 'nvidia' - elif (commandOut.lower().find('radeon') > -1): - self.gpudev = 'ati' # create dictionaries self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', '9':'gpu', 'a':'gputemp', @@ -124,24 +103,13 @@ class pyTextWidget(plasmascript.Applet): plasmascript.Applet.showConfigurationInterface(self) - def showTooltip(self, text): - """function to create and set tooltip""" - tooltip = Plasma.ToolTipContent() - tooltip.setImage(KIcon(self.icon())) - tooltip.setSubText(text) - tooltip.setAutohide(False) - Plasma.ToolTipManager.self().setContent(self.applet, tooltip) - Plasma.ToolTipManager.self().registerWidget(self.applet) - - def startPolling(self): try: self.timer.start() - QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel) self.updateLabel() - self.showTooltip('') + self.tooltip.setSubText('') except Exception as (strerror): - self.showTooltip(str(strerror)) + self.tooltip.setSubText(str(strerror)) self.label_error = Plasma.Label(self.applet) self.label_error.setText('ERROR') self.layout.addItem(self.label_error) @@ -149,19 +117,10 @@ class pyTextWidget(plasmascript.Applet): def updateLabel(self): """function to update label""" - if (self.gpuBool == 1): - self.gpuText() - self.gpuChecker.label_exit = 2 - if (self.gputempBool == 1): - self.gputempText() - self.gpuTempChecker.label_exit = 2 if ((self.memBool == 1) and (self.memInMb == False)): self.memText() if ((self.swapBool == 1) and (self.swapInMb == False)): self.swapText() - if (self.hddtempBool == 1): - self.hddtempText() - self.hddTempChecker.label_exit = 2 if (self.batBool == 1): self.batText() @@ -193,36 +152,6 @@ class pyTextWidget(plasmascript.Applet): self.label_bat.setText(text) - def gpuText(self): - """function to set gpu text""" - if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat): - line = self.gpuFormat.split('$gpu')[0] + self.gpuChecker.gpu + self.gpuFormat.split('$gpu')[1] - else: - line = self.gpuFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_gpu.setText(text) - - - def gputempText(self): - """function to set gpu temperature text""" - if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat): - line = self.gputempFormat.split('$gputemp')[0] + self.gpuTempChecker.gputemp + self.gputempFormat.split('$gputemp')[1] - else: - line = self.gputempFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_gputemp.setText(text) - - - def hddtempText(self): - """function to set hdd temperature text""" - if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat): - line = self.hddtempFormat.split('@@')[0] + self.hddTempChecker.hddtemp + self.hddtempFormat.split('@@')[2] - else: - line = self.hddtempFormat - text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1] - self.label_hddtemp.setText(text) - - def memText(self): """function to set mem text""" full = self.mem_uf + self.mem_free diff --git a/source/contents/code/reinit.py b/source/contents/code/reinit.py index 75d2b3a..87b604c 100644 --- a/source/contents/code/reinit.py +++ b/source/contents/code/reinit.py @@ -1,9 +1,8 @@ +# -*- coding: utf-8 -*- + from PyQt4.QtCore import * from PyKDE4.plasma import Plasma import config -import gpuchecker -import gputempchecker -import hddtempchecker @@ -14,22 +13,22 @@ class Reinit(): def reinit(self): """function to reinitializate widget""" - self.parent.settings = config.Config(self.parent) - self.parent.interval = int(self.parent.settings.get('interval', 2000)) - self.parent.font_family = str(self.parent.settings.get('font_family', 'Terminus')) - self.parent.font_size = int(self.parent.settings.get('font_size', 12)) - self.parent.font_color = str(self.parent.settings.get('font_color', '#000000')) - self.parent.font_style = str(self.parent.settings.get('font_style', 'normal')) - self.parent.font_weight = int(self.parent.settings.get('font_weight', 400)) + settings = config.Config(self.parent) + self.parent.interval = settings.get('interval', 2000).toInt()[0] + self.parent.font_family = str(settings.get('font_family', 'Terminus')) + self.parent.font_size = settings.get('font_size', 12).toInt()[0] + self.parent.font_color = str(settings.get('font_color', '#000000')) + self.parent.font_style = str(settings.get('font_style', 'normal')) + self.parent.font_weight = settings.get('font_weight', 400).toInt()[0] self.parent.formatLine = "

$LINE

" - self.parent.label_order = str(self.parent.settings.get('label_order', '1345')) + self.parent.label_order = str(settings.get('label_order', '1345')) for label in self.parent.dict_orders.values(): if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')): - exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 1))') + exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 1))') else: - exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 0))') + exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))') # small function for update if errors exist summ = 0 for label in self.parent.dict_orders.values(): @@ -40,14 +39,14 @@ class Reinit(): exec ('self.parent.' + label + 'Bool = 1') else: exec ('self.parent.' + label + 'Bool = 0') - exec ('self.parent.settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)') + exec ('settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)') self.parent.label_order = '1345' - self.parent.settings.set('label_order', self.parent.label_order) + settings.set('label_order', self.parent.label_order) for order in self.parent.label_order: if (order == "1"): if (self.parent.cpuBool == 1): - self.parent.cpuFormat = str(self.parent.settings.get('cpuFormat', '[cpu: $cpu%]')) + self.parent.cpuFormat = str(settings.get('cpuFormat', '[cpu: $cpu%]')) if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat): self.parent.label_cpu0 = Plasma.Label(self.parent.applet) self.parent.label_cpu1 = Plasma.Label(self.parent.applet) @@ -81,7 +80,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_cpu) elif (order == "2"): if (self.parent.tempBool == 1): - self.parent.tempFormat = str(self.parent.settings.get('tempFormat', '[temp: $temp°C]')) + self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp°C]')) self.parent.label_temp = Plasma.Label(self.parent.applet) if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat): line = self.parent.tempFormat.split('$temp')[0] + '----' + self.parent.tempFormat.split('$temp')[1] @@ -92,7 +91,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_temp) elif (order == "3"): if (self.parent.memBool == 1): - self.parent.memFormat = str(self.parent.settings.get('memFormat', '[mem: $mem%]')) + self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]')) if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat): self.parent.memInMb = True text = self.parent.formatLine.split('$LINE')[0] + self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[1] + self.parent.formatLine.split('$LINE')[1] @@ -110,7 +109,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_mem) elif (order == "4"): if (self.parent.swapBool == 1): - self.parent.swapFormat = str(self.parent.settings.get('swapFormat', '[swap: $swap%]')) + self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]')) if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat): self.parent.swapInMb = True text = self.parent.formatLine.split('$LINE')[0] + self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[1] + self.parent.formatLine.split('$LINE')[1] @@ -127,12 +126,12 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_swap) elif (order == "5"): if (self.parent.netBool == 1): - self.parent.netNonFormat = str(self.parent.settings.get('netNonFormat', '[net: $netKB/s]')) + self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]')) if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat): self.parent.netdev = self.parent.netNonFormat.split('@@')[1] self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2] else: - self.parent.num_dev = int(self.parent.settings.get('num_dev', 0)) + self.parent.num_dev = int(settings.get('num_dev', 0)) self.parent.setupNetdev() if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat): self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1] @@ -156,9 +155,9 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_netUp) elif (order == "6"): if (self.parent.batBool == 1): - self.parent.batFormat = str(self.parent.settings.get('batFormat', '[bat: $bat%$ac]')) - self.parent.battery_device= str(self.parent.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')) - self.parent.ac_device = str(self.parent.settings.get('ac_device', '/sys/class/power_supply/AC/online')) + self.parent.batFormat = str(settings.get('batFormat', '[bat: $bat%$ac]')) + self.parent.battery_device= str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')) + self.parent.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online')) self.parent.label_bat = Plasma.Label(self.parent.applet) line = self.parent.batFormat if (line.split('$ac')[0] != line): @@ -170,7 +169,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_bat) elif (order == "7"): if (self.parent.cpuclockBool == 1): - self.parent.cpuclockFormat = str(self.parent.settings.get('cpuclockFormat', '[mhz: $cpucl]')) + self.parent.cpuclockFormat = str(settings.get('cpuclockFormat', '[mhz: $cpucl]')) if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat): self.parent.label_cpuclock0 = Plasma.Label(self.parent.applet) self.parent.label_cpuclock1 = Plasma.Label(self.parent.applet) @@ -204,7 +203,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_cpuclock) elif (order == "8"): if (self.parent.uptimeBool == 1): - self.parent.uptimeFormat = str(self.parent.settings.get('uptimeFormat', '[uptime: $uptime]')) + self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]')) self.parent.label_uptime = Plasma.Label(self.parent.applet) if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat): line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1] @@ -215,7 +214,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_uptime) elif (order == "9"): if (self.parent.gpuBool == 1): - self.parent.gpuFormat = str(self.parent.settings.get('gpuFormat', '[gpu: $gpu%]')) + self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]')) self.parent.label_gpu = Plasma.Label(self.parent.applet) if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat): line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1] @@ -226,7 +225,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_gpu) elif (order == "a"): if (self.parent.gputempBool == 1): - self.parent.gputempFormat = str(self.parent.settings.get('gputempFormat', '[gpu temp: $gputemp°C]')) + self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp°C]')) self.parent.label_gputemp = Plasma.Label(self.parent.applet) if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat): line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1] @@ -237,7 +236,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_gputemp) elif (order == "b"): if (self.parent.hddBool == 1): - self.parent.hddFormat = str(self.parent.settings.get('hddFormat', '[hdd: @@/@@%]')) + self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: @@/@@%]')) if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat): self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';') line = self.parent.hddFormat.split('@@')[0] @@ -262,7 +261,7 @@ class Reinit(): self.parent.layout.addItem(self.parent.label_hdd0) elif (order == "c"): if (self.parent.hddtempBool == 1): - self.parent.hddtempFormat = str(self.parent.settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]')) + self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]')) self.parent.label_hddtemp = Plasma.Label(self.parent.applet) if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat): line = self.parent.hddtempFormat.split('@@')[0] + '----' + self.parent.hddtempFormat.split('@@')[2] @@ -277,17 +276,8 @@ class Reinit(): self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground) self.parent.resize(10,10) - # create threading + # create dataengines self.parent.dataengine.connectToEngine() - self.parent.timer = QTimer() + self.parent.timer.setInterval(self.parent.interval) - if (self.parent.gpuBool == 1): - self.parent.gpuChecker = gpuchecker.GpuThread(self.parent.interval, self.parent.gpudev) - self.parent.gpuChecker.start() - if (self.parent.gputempBool == 1): - self.parent.gpuTempChecker = gputempchecker.GpuTempThread(self.parent.interval, self.parent.gpudev) - self.parent.gpuTempChecker.start() - if (self.parent.hddtempBool ==1): - self.parent.hddTempChecker = hddtempchecker.HddTempThread(self.parent.interval, self.parent.hddtempFormat.split('@@')[1]) - self.parent.hddTempChecker.start() self.parent.startPolling() diff --git a/source/contents/code/util.py b/source/contents/code/util.py index 32b87db..c2ac27c 100644 --- a/source/contents/code/util.py +++ b/source/contents/code/util.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import os from shutil import copyfile from PyKDE4.kdecore import * +import os @@ -10,16 +10,19 @@ class Util(): def __init__(self, applet): self.applet = applet + def createDirectory(self, name): if not os.path.isdir(name): try: os.mkdir(name) except: print 'Failed to create directory: ' + name - + + def kdeHome(self): return unicode(KGlobal.dirs().localkdedir()) - + + def createNotifyrc(self): print '[%s] creating notifyrc' % (self.applet._name) self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name) @@ -28,9 +31,10 @@ class Util(): destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name) copyfile(source, destination) + def createConfig(self): self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name) source = self.applet.package().path() + 'contents/misc/%s.ini' % self.applet._name destination = self.kdeHome() + 'share/apps/%s/%s.ini' % (self.applet._name, self.applet._name) - copyfile(source, destination) \ No newline at end of file + copyfile(source, destination) diff --git a/source/metadata.desktop b/source/metadata.desktop index fec9634..e235d9a 100644 --- a/source/metadata.desktop +++ b/source/metadata.desktop @@ -1,17 +1,19 @@ [Desktop Entry] Encoding=UTF-8 Name=Py Text Monitor -Type=Service ServiceTypes=Plasma/Applet +Type=Service Icon=utilities-system-monitor + X-Plasma-API=python X-Plasma-MainScript=code/main.py + X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=py-text-monitor -X-KDE-PluginInfo-Version=1.3.1 +X-KDE-PluginInfo-Version=1.3.2 X-KDE-PluginInfo-Website=http://kde-look.org/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true \ No newline at end of file +X-KDE-PluginInfo-EnabledByDefault=true