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
This commit is contained in:
arcan1s 2013-05-24 19:48:10 +04:00
parent 9243220505
commit 4c59e7e892
18 changed files with 447 additions and 415 deletions

1
README
View File

@ -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. 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: 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!

BIN
extsysmon-1.0.zip Normal file

Binary file not shown.

View File

@ -0,0 +1,95 @@
# -*- 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)

View File

@ -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

3
install_extsysmon.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
plasmapkg -t dataengine -i extsysmon-1.0.zip

Binary file not shown.

View File

@ -1,27 +1,39 @@
class ConfigAccepted: # -*- coding: utf-8 -*-
def __init__(self, parent):
from PyQt4.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
import config
class ConfigDefinition:
def __init__(self, parent, configpage):
"""class definition""" """class definition"""
self.parent = parent self.parent = parent
self.configpage = configpage
def configAccepted(self): def configAccepted(self):
"""function to accept settings""" """function to accept settings"""
settings = config.Config(self.parent)
# update local variables # update local variables
self.parent.interval = int(self.parent.configpage.ui.spinBox_interval.value()) self.parent.interval = self.configpage.ui.spinBox_interval.value()
self.parent.settings.set('interval', self.parent.interval) settings.set('interval', self.parent.interval)
self.parent.font_family = str(self.parent.configpage.ui.fontComboBox.currentFont().family()) self.parent.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
self.parent.settings.set('font_family', self.parent.font_family) settings.set('font_family', self.parent.font_family)
self.parent.font_size = int(self.parent.configpage.ui.spinBox_fontSize.value()) self.parent.font_size = self.configpage.ui.spinBox_fontSize.value()
self.parent.settings.set('font_size', self.parent.font_size) settings.set('font_size', self.parent.font_size)
self.parent.font_color = str(self.parent.configpage.ui.kcolorcombo.color().name()) self.parent.font_color = str(self.configpage.ui.kcolorcombo.color().name())
self.parent.settings.set('font_color', self.parent.font_color) settings.set('font_color', self.parent.font_color)
if (self.parent.configpage.ui.comboBox_style.currentIndex() == 0): if (self.configpage.ui.comboBox_style.currentIndex() == 0):
self.parent.font_style = 'normal' self.parent.font_style = 'normal'
else: else:
self.parent.font_style = 'italic' self.parent.font_style = 'italic'
self.parent.settings.set('font_style', self.parent.font_style) settings.set('font_style', self.parent.font_style)
self.parent.font_weight = int(self.parent.configpage.ui.spinBox_weight.value()) self.parent.font_weight = self.configpage.ui.spinBox_weight.value()
self.parent.settings.set('font_weight', self.parent.font_weight) settings.set('font_weight', self.parent.font_weight)
# disconnecting from source and clear layout # disconnecting from source and clear layout
if (self.parent.uptimeBool == 1): if (self.parent.uptimeBool == 1):
@ -61,11 +73,11 @@ class ConfigAccepted:
self.parent.label_temp.setText('') self.parent.label_temp.setText('')
self.parent.layout.removeItem(self.parent.label_temp) self.parent.layout.removeItem(self.parent.label_temp)
if (self.parent.gpuBool == 1): if (self.parent.gpuBool == 1):
self.parent.gpuChecker.stop() self.parent.extsysmon.disconnectSource("gpu", self.parent)
self.parent.label_gpu.setText('') self.parent.label_gpu.setText('')
self.parent.layout.removeItem(self.parent.label_gpu) self.parent.layout.removeItem(self.parent.label_gpu)
if (self.parent.gputempBool == 1): if (self.parent.gputempBool == 1):
self.parent.gpuTempChecker.stop() self.parent.extsysmon.disconnectSource("gputemp", self.parent)
self.parent.label_gputemp.setText('') self.parent.label_gputemp.setText('')
self.parent.layout.removeItem(self.parent.label_gputemp) self.parent.layout.removeItem(self.parent.label_gputemp)
if (self.parent.memBool == 1): if (self.parent.memBool == 1):
@ -91,7 +103,7 @@ class ConfigAccepted:
self.parent.layout.removeItem(self.parent.label_hdd0) self.parent.layout.removeItem(self.parent.label_hdd0)
self.parent.layout.removeItem(self.parent.label_hdd1) self.parent.layout.removeItem(self.parent.label_hdd1)
if (self.parent.hddtempBool == 1): if (self.parent.hddtempBool == 1):
self.parent.hddTempChecker.stop() self.parent.extsysmon.disconnectSource("hddtemp", self.parent)
self.parent.label_hddtemp.setText('') self.parent.label_hddtemp.setText('')
self.parent.layout.removeItem(self.parent.label_hddtemp) self.parent.layout.removeItem(self.parent.label_hddtemp)
if (self.parent.netBool == 1): if (self.parent.netBool == 1):
@ -108,30 +120,68 @@ class ConfigAccepted:
self.parent.label_order = "------------" self.parent.label_order = "------------"
for label in self.parent.dict_orders.keys(): for label in self.parent.dict_orders.keys():
if (self.parent.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2): if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2):
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 1') exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 1')
pos = self.parent.configpage.sliders[self.parent.dict_orders[label]].value() - 1 pos = self.configpage.sliders[self.parent.dict_orders[label]].value() - 1
self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:] self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:]
else: else:
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 0') exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 0')
if (self.parent.dict_orders[label] == 'net'): if (self.parent.dict_orders[label] == 'net'):
exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.parent.configpage.lineedits[self.parent.dict_orders[label]].text())') exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)') exec ('settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
else: else:
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.parent.configpage.lineedits[self.parent.dict_orders[label]].text())') exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)') exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
exec ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)') exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
if (self.parent.dict_orders[label] == 'net'): if (self.parent.dict_orders[label] == 'net'):
self.parent.num_dev = int(self.parent.configpage.ui.comboBox_numNet.currentIndex()) self.parent.num_dev = self.configpage.ui.comboBox_numNet.currentIndex()
self.parent.settings.set('num_dev', self.parent.num_dev) settings.set('num_dev', self.parent.num_dev)
elif (self.parent.dict_orders[label] == 'bat'): elif (self.parent.dict_orders[label] == 'bat'):
self.parent.battery_device = str(self.parent.configpage.ui.lineEdit_batdev.text()) self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
self.parent.ac_device = str(self.parent.configpage.ui.lineEdit_acdev.text()) self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
self.parent.settings.set('battery_device', self.parent.battery_device) settings.set('battery_device', self.parent.battery_device)
self.parent.settings.set('ac_device', self.parent.ac_device) settings.set('ac_device', self.parent.ac_device)
self.parent.label_order = ''.join(self.parent.label_order.split('-')) self.parent.label_order = ''.join(self.parent.label_order.split('-'))
self.parent.settings.set('label_order', self.parent.label_order) settings.set('label_order', self.parent.label_order)
# reinitializate # reinitializate
self.parent.reinit.reinit() self.parent.reinit.reinit()
def createConfigurationInterface(self, parent):
"""function to setup configuration window"""
settings = config.Config(self.parent)
font = QFont(str(settings.get('font_family', 'Terminus')), settings.get('font_size', 12).toInt()[0], 400, False)
self.configpage.ui.spinBox_interval.setValue(settings.get('interval', 2000).toInt()[0])
self.configpage.ui.fontComboBox.setCurrentFont(font)
self.configpage.ui.spinBox_fontSize.setValue(settings.get('font_size', 12).toInt()[0])
self.configpage.ui.kcolorcombo.setColor(QColor(str(settings.get('font_color', '#000000'))))
font = str(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(settings.get('font_weight', 400).toInt()[0])
for label in self.parent.dict_orders.keys():
exec ('bool = self.parent.' + self.parent.dict_orders[label] + 'Bool')
if (bool == 1):
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(2)
self.configpage.sliders[self.parent.dict_orders[label]].setValue(self.parent.label_order.find(label)+1)
else:
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(0)
if (self.parent.dict_orders[label] == 'net'):
self.configpage.ui.comboBox_numNet.setCurrentIndex(settings.get('num_dev', 0).toInt()[0])
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
else:
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'Format', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
if (self.parent.dict_orders[label] == 'bat'):
self.configpage.ui.lineEdit_batdev.setText(str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
self.configpage.ui.lineEdit_acdev.setText(str(settings.get('ac_device', '/sys/class/power_supply/AC/online')))
# add config page
page = parent.addPage(self.configpage, i18n(self.parent.name()))
page.setIcon(KIcon(self.parent.icon()))
parent.okClicked.connect(self.configAccepted)

View File

@ -9,7 +9,7 @@ from PyKDE4 import plasmascript
class ConfigWindow(QWidget): class ConfigWindow(QWidget):
def __init__(self, parent, settings): def __init__(self, parent):
"""settings window definition""" """settings window definition"""
QWidget.__init__(self) QWidget.__init__(self)
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self) self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma from PyKDE4.plasma import Plasma
@ -14,6 +16,9 @@ class DataEngine:
def connectToEngine(self): def connectToEngine(self):
"""function to initializate engine""" """function to initializate engine"""
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor") self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
if ((self.parent.gputempBool == 1) or (self.parent.gpuBool == 1) or (self.parent.hddtempBool == 1)):
self.parent.extsysmon = self.parent.dataEngine("ext-sysmon")
if (self.parent.uptimeBool == 1): if (self.parent.uptimeBool == 1):
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval) self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
if (self.parent.cpuBool == 1): if (self.parent.cpuBool == 1):
@ -26,32 +31,38 @@ class DataEngine:
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat): if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
for core in range(self.parent.numCores): for core in range(self.parent.numCores):
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval) self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval)
if (self.parent.netBool == 1):
self.parent.updateNetdev = 0
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
if (self.parent.tempBool == 1): if (self.parent.tempBool == 1):
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval) self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
if (self.parent.gpuBool == 1):
self.parent.extsysmon.connectSource("gpu", self.parent, self.parent.interval)
if (self.parent.gputempBool == 1):
self.parent.extsysmon.connectSource("gputemp", self.parent, self.parent.interval)
if (self.parent.memBool == 1): if (self.parent.memBool == 1):
if (self.parent.memInMb): if (self.parent.memInMb):
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval) self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval)
else: else:
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, 200) self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, 200) self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, 200) self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, int(self.parent.interval*0.5))
if (self.parent.swapBool == 1): if (self.parent.swapBool == 1):
if (self.parent.swapInMb): if (self.parent.swapInMb):
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval) self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval)
else: else:
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, 200) self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, 200) self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, int(self.parent.interval*0.5))
if (self.parent.hddBool == 1): if (self.parent.hddBool == 1):
for mount in self.parent.mountPoints: for mount in self.parent.mountPoints:
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval) self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
if (self.parent.hddtempBool == 1):
self.parent.extsysmon.connectSource("hddtemp", self.parent, self.parent.interval)
if (self.parent.netBool == 1):
self.parent.updateNetdev = 0
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
def dataUpdated(self, sourceName, data): def dataUpdated(self, sourceName, data):
"""function to refresh data""" """function to refresh data"""
try:
if (sourceName == "system/uptime"): if (sourceName == "system/uptime"):
value = int(round(float(data[QString(u'value')]), 1)) value = int(round(float(data[QString(u'value')]), 1))
uptimeText = '%3sd%2sh%2sm' % (str(int(value/(24*60*60))), int(value/60/60)-int(value/24/60/60)*24, (value-value%60)/60%60) uptimeText = '%3sd%2sh%2sm' % (str(int(value/(24*60*60))), int(value/60/60)-int(value/24/60/60)*24, (value-value%60)/60%60)
@ -193,3 +204,32 @@ class DataEngine:
self.parent.label_swap.setText(text) self.parent.label_swap.setText(text)
else: else:
self.parent.swap_used = float(data[QString(u'value')]) self.parent.swap_used = float(data[QString(u'value')])
elif (sourceName == "gpu"):
value = str(data[QString(u'GPU')])
gpuText = "%4s" % (value)
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
line = self.parent.gpuFormat.split('$gpu')[0] + gpuText + self.parent.gpuFormat.split('$gpu')[1]
else:
line = self.parent.gpuFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gpu.setText(text)
elif (sourceName == "gputemp"):
value = str(data[QString(u'GPUTemp')])
gputempText = "%4s" % (value)
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
line = self.parent.gputempFormat.split('$gputemp')[0] + gputempText + self.parent.gputempFormat.split('$gputemp')[1]
else:
line = self.parent.gputempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gputemp.setText(text)
elif (sourceName == "hddtemp"):
value = str(data[QString(self.parent.hddtempFormat.split('@@')[1])])
hddtempText = "%4s" % (value)
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
line = self.parent.hddtempFormat.split('@@')[0] + hddtempText + self.parent.hddtempFormat.split('@@')[2]
else:
line = self.parent.hddtempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hddtemp.setText(text)
except:
pass

View File

@ -1,38 +0,0 @@
import commands, time
from PyQt4.QtCore import QThread
class GpuThread(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.gpu = '----'
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 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

View File

@ -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

View File

@ -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

View File

@ -9,7 +9,7 @@ from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma from PyKDE4.plasma import Plasma
import commands, os, time import commands, os, time
import configaccepted import configdef
import configwindow import configwindow
import dataengine import dataengine
import reinit import reinit
@ -20,57 +20,42 @@ from util import *
class pyTextWidget(plasmascript.Applet): class pyTextWidget(plasmascript.Applet):
def __init__(self, parent, args=None): def __init__(self, parent, args=None):
"""widget definition""" """widget definition"""
plasmascript.Applet.__init__(self,parent) plasmascript.Applet.__init__(self, parent)
def init(self): def init(self):
"""function to initializate widget""" """function to initializate widget"""
self._name = str(self.package().metadata().pluginName()) self._name = str(self.package().metadata().pluginName())
self.initTooltip()
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet) self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
self.configAccepted = configaccepted.ConfigAccepted(self)
self.dataengine = dataengine.DataEngine(self) self.dataengine = dataengine.DataEngine(self)
self.reinit = reinit.Reinit(self) self.reinit = reinit.Reinit(self)
self.timer = QTimer()
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
self.setupVar() self.setupVar()
self.reinit.reinit() self.reinit.reinit()
self.setHasConfigurationInterface(True) self.setHasConfigurationInterface(True)
def createConfigurationInterface(self, parent): def createConfigurationInterface(self, parent):
"""function to setup configuration window""" """function to setup configuration window"""
self.configpage = configwindow.ConfigWindow(self, self.settings) self.configpage = configwindow.ConfigWindow(self)
self.configdef = configdef.ConfigDefinition(self, self.configpage)
self.configdef.createConfigurationInterface(parent)
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 def initTooltip(self):
page = parent.addPage(self.configpage, i18n(self.name())) """function to create tooltip"""
page.setIcon(KIcon(self.icon())) self.tooltip = Plasma.ToolTipContent()
self.tooltip.setMainText("PyTetMonitor")
parent.okClicked.connect(self.configAccepted.configAccepted) self.tooltip.setSubText('')
Plasma.ToolTipManager.self().registerWidget(self.applet)
# show tooltip
#Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
def setupNetdev(self): def setupNetdev(self):
@ -102,12 +87,6 @@ class pyTextWidget(plasmascript.Applet):
# setup temperature device # setup temperature device
commandOut = commands.getoutput("sensors | grep Physical -B2") commandOut = commands.getoutput("sensors | grep Physical -B2")
self.tempdev = "lmsensors/"+commandOut.split("\n")[0]+"/"+'_'.join(commandOut.split("\n")[2].split(":")[0].split()) 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 # create dictionaries
self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', '9':'gpu', 'a':'gputemp', 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) 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): def startPolling(self):
try: try:
self.timer.start() self.timer.start()
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
self.updateLabel() self.updateLabel()
self.showTooltip('') self.tooltip.setSubText('')
except Exception as (strerror): except Exception as (strerror):
self.showTooltip(str(strerror)) self.tooltip.setSubText(str(strerror))
self.label_error = Plasma.Label(self.applet) self.label_error = Plasma.Label(self.applet)
self.label_error.setText('<font color="red">ERROR</font>') self.label_error.setText('<font color="red">ERROR</font>')
self.layout.addItem(self.label_error) self.layout.addItem(self.label_error)
@ -149,19 +117,10 @@ class pyTextWidget(plasmascript.Applet):
def updateLabel(self): def updateLabel(self):
"""function to update label""" """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)): if ((self.memBool == 1) and (self.memInMb == False)):
self.memText() self.memText()
if ((self.swapBool == 1) and (self.swapInMb == False)): if ((self.swapBool == 1) and (self.swapInMb == False)):
self.swapText() self.swapText()
if (self.hddtempBool == 1):
self.hddtempText()
self.hddTempChecker.label_exit = 2
if (self.batBool == 1): if (self.batBool == 1):
self.batText() self.batText()
@ -193,36 +152,6 @@ class pyTextWidget(plasmascript.Applet):
self.label_bat.setText(text) 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): def memText(self):
"""function to set mem text""" """function to set mem text"""
full = self.mem_uf + self.mem_free full = self.mem_uf + self.mem_free

View File

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyKDE4.plasma import Plasma from PyKDE4.plasma import Plasma
import config import config
import gpuchecker
import gputempchecker
import hddtempchecker
@ -14,22 +13,22 @@ class Reinit():
def reinit(self): def reinit(self):
"""function to reinitializate widget""" """function to reinitializate widget"""
self.parent.settings = config.Config(self.parent) settings = config.Config(self.parent)
self.parent.interval = int(self.parent.settings.get('interval', 2000)) self.parent.interval = settings.get('interval', 2000).toInt()[0]
self.parent.font_family = str(self.parent.settings.get('font_family', 'Terminus')) self.parent.font_family = str(settings.get('font_family', 'Terminus'))
self.parent.font_size = int(self.parent.settings.get('font_size', 12)) self.parent.font_size = settings.get('font_size', 12).toInt()[0]
self.parent.font_color = str(self.parent.settings.get('font_color', '#000000')) self.parent.font_color = str(settings.get('font_color', '#000000'))
self.parent.font_style = str(self.parent.settings.get('font_style', 'normal')) self.parent.font_style = str(settings.get('font_style', 'normal'))
self.parent.font_weight = int(self.parent.settings.get('font_weight', 400)) self.parent.font_weight = settings.get('font_weight', 400).toInt()[0]
self.parent.formatLine = "<pre><p align=\"center\"><span style=\" font-family:'" + self.parent.font_family + "'; font-style:" + self.parent.font_style self.parent.formatLine = "<pre><p align=\"center\"><span style=\" font-family:'" + self.parent.font_family + "'; font-style:" + self.parent.font_style
self.parent.formatLine = self.parent.formatLine + "; font-size:" + str(self.parent.font_size) + "pt; font-weight:" + str(self.parent.font_weight) self.parent.formatLine = self.parent.formatLine + "; font-size:" + str(self.parent.font_size) + "pt; font-weight:" + str(self.parent.font_weight)
self.parent.formatLine = self.parent.formatLine + "; color:" + self.parent.font_color + ";\">$LINE</span></p></pre>" self.parent.formatLine = self.parent.formatLine + "; color:" + self.parent.font_color + ";\">$LINE</span></p></pre>"
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(): for label in self.parent.dict_orders.values():
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')): 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: 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 # small function for update if errors exist
summ = 0 summ = 0
for label in self.parent.dict_orders.values(): for label in self.parent.dict_orders.values():
@ -40,14 +39,14 @@ class Reinit():
exec ('self.parent.' + label + 'Bool = 1') exec ('self.parent.' + label + 'Bool = 1')
else: else:
exec ('self.parent.' + label + 'Bool = 0') 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.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: for order in self.parent.label_order:
if (order == "1"): if (order == "1"):
if (self.parent.cpuBool == 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): if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
self.parent.label_cpu0 = Plasma.Label(self.parent.applet) self.parent.label_cpu0 = Plasma.Label(self.parent.applet)
self.parent.label_cpu1 = 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) self.parent.layout.addItem(self.parent.label_cpu)
elif (order == "2"): elif (order == "2"):
if (self.parent.tempBool == 1): if (self.parent.tempBool == 1):
self.parent.tempFormat = str(self.parent.settings.get('tempFormat', '[temp: $temp&deg;C]')) self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp&deg;C]'))
self.parent.label_temp = Plasma.Label(self.parent.applet) self.parent.label_temp = Plasma.Label(self.parent.applet)
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat): if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
line = self.parent.tempFormat.split('$temp')[0] + '----' + self.parent.tempFormat.split('$temp')[1] 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) self.parent.layout.addItem(self.parent.label_temp)
elif (order == "3"): elif (order == "3"):
if (self.parent.memBool == 1): 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): if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
self.parent.memInMb = True 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] 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) self.parent.layout.addItem(self.parent.label_mem)
elif (order == "4"): elif (order == "4"):
if (self.parent.swapBool == 1): 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): if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
self.parent.swapInMb = True 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] 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) self.parent.layout.addItem(self.parent.label_swap)
elif (order == "5"): elif (order == "5"):
if (self.parent.netBool == 1): 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): if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat):
self.parent.netdev = self.parent.netNonFormat.split('@@')[1] self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2] self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
else: 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() self.parent.setupNetdev()
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat): 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] 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) self.parent.layout.addItem(self.parent.label_netUp)
elif (order == "6"): elif (order == "6"):
if (self.parent.batBool == 1): if (self.parent.batBool == 1):
self.parent.batFormat = str(self.parent.settings.get('batFormat', '[bat: $bat%$ac]')) self.parent.batFormat = str(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.battery_device= str(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.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
self.parent.label_bat = Plasma.Label(self.parent.applet) self.parent.label_bat = Plasma.Label(self.parent.applet)
line = self.parent.batFormat line = self.parent.batFormat
if (line.split('$ac')[0] != line): if (line.split('$ac')[0] != line):
@ -170,7 +169,7 @@ class Reinit():
self.parent.layout.addItem(self.parent.label_bat) self.parent.layout.addItem(self.parent.label_bat)
elif (order == "7"): elif (order == "7"):
if (self.parent.cpuclockBool == 1): 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): if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
self.parent.label_cpuclock0 = Plasma.Label(self.parent.applet) self.parent.label_cpuclock0 = Plasma.Label(self.parent.applet)
self.parent.label_cpuclock1 = 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) self.parent.layout.addItem(self.parent.label_cpuclock)
elif (order == "8"): elif (order == "8"):
if (self.parent.uptimeBool == 1): 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) self.parent.label_uptime = Plasma.Label(self.parent.applet)
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat): 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] 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) self.parent.layout.addItem(self.parent.label_uptime)
elif (order == "9"): elif (order == "9"):
if (self.parent.gpuBool == 1): 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) self.parent.label_gpu = Plasma.Label(self.parent.applet)
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat): if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1] 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) self.parent.layout.addItem(self.parent.label_gpu)
elif (order == "a"): elif (order == "a"):
if (self.parent.gputempBool == 1): if (self.parent.gputempBool == 1):
self.parent.gputempFormat = str(self.parent.settings.get('gputempFormat', '[gpu temp: $gputemp&deg;C]')) self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp&deg;C]'))
self.parent.label_gputemp = Plasma.Label(self.parent.applet) self.parent.label_gputemp = Plasma.Label(self.parent.applet)
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat): if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1] 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) self.parent.layout.addItem(self.parent.label_gputemp)
elif (order == "b"): elif (order == "b"):
if (self.parent.hddBool == 1): 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): if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';') self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
line = self.parent.hddFormat.split('@@')[0] line = self.parent.hddFormat.split('@@')[0]
@ -262,7 +261,7 @@ class Reinit():
self.parent.layout.addItem(self.parent.label_hdd0) self.parent.layout.addItem(self.parent.label_hdd0)
elif (order == "c"): elif (order == "c"):
if (self.parent.hddtempBool == 1): if (self.parent.hddtempBool == 1):
self.parent.hddtempFormat = str(self.parent.settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@&deg;C]')) self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@&deg;C]'))
self.parent.label_hddtemp = Plasma.Label(self.parent.applet) self.parent.label_hddtemp = Plasma.Label(self.parent.applet)
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat): if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
line = self.parent.hddtempFormat.split('@@')[0] + '----' + self.parent.hddtempFormat.split('@@')[2] 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.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.parent.resize(10,10) self.parent.resize(10,10)
# create threading # create dataengines
self.parent.dataengine.connectToEngine() self.parent.dataengine.connectToEngine()
self.parent.timer = QTimer()
self.parent.timer.setInterval(self.parent.interval) 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() self.parent.startPolling()

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
from shutil import copyfile from shutil import copyfile
from PyKDE4.kdecore import * from PyKDE4.kdecore import *
import os
@ -10,6 +10,7 @@ class Util():
def __init__(self, applet): def __init__(self, applet):
self.applet = applet self.applet = applet
def createDirectory(self, name): def createDirectory(self, name):
if not os.path.isdir(name): if not os.path.isdir(name):
try: try:
@ -17,9 +18,11 @@ class Util():
except: except:
print 'Failed to create directory: ' + name print 'Failed to create directory: ' + name
def kdeHome(self): def kdeHome(self):
return unicode(KGlobal.dirs().localkdedir()) return unicode(KGlobal.dirs().localkdedir())
def createNotifyrc(self): def createNotifyrc(self):
print '[%s] creating notifyrc' % (self.applet._name) print '[%s] creating notifyrc' % (self.applet._name)
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name) self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
@ -28,6 +31,7 @@ class Util():
destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name) destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name)
copyfile(source, destination) copyfile(source, destination)
def createConfig(self): def createConfig(self):
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name) self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)

View File

@ -1,15 +1,17 @@
[Desktop Entry] [Desktop Entry]
Encoding=UTF-8 Encoding=UTF-8
Name=Py Text Monitor Name=Py Text Monitor
Type=Service
ServiceTypes=Plasma/Applet ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor Icon=utilities-system-monitor
X-Plasma-API=python X-Plasma-API=python
X-Plasma-MainScript=code/main.py X-Plasma-MainScript=code/main.py
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=py-text-monitor 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-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=