mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
New release (TRUE!) 1.3.1:
* refactoring * bug fixes + multithreads - creating threads for gpu and hdd
This commit is contained in:
parent
ff0410859b
commit
f08ccbd45d
8
README
8
README
@ -10,17 +10,19 @@ For edited output you must open Settings window and setup output format in lines
|
||||
label "$ccpu" means load CPU for each core, %
|
||||
label "$cpucl" - average cpu clock, MHz
|
||||
label "$ccpucl" - cpu clock for each core, MHz
|
||||
label "$temp" - average temperature in system (if doesn't work please let me know)
|
||||
label "$gpu" -GPU usage, %
|
||||
label "$temp" - average temperature in system
|
||||
label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed
|
||||
label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
|
||||
label "$mem" - usage memory, %
|
||||
label "$memmb" - usage memory, MB
|
||||
label "$swap" - swap, %
|
||||
label "$swapmb" - swap, MB
|
||||
label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@"
|
||||
label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed
|
||||
label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature
|
||||
label "$net" - download and upload speed, KB/s. You may also specify the number of devices (1 or 2) - without their names. And you may specify network device: something like @@eth0@@
|
||||
label "$netdev" - current network device
|
||||
label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent
|
||||
label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online
|
||||
|
||||
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.
|
||||
|
Binary file not shown.
137
source/contents/code/configaccepted.py
Normal file
137
source/contents/code/configaccepted.py
Normal file
@ -0,0 +1,137 @@
|
||||
class ConfigAccepted:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
# update local variables
|
||||
self.parent.interval = int(self.parent.configpage.ui.spinBox_interval.value())
|
||||
self.parent.settings.set('interval', self.parent.interval)
|
||||
self.parent.font_family = str(self.parent.configpage.ui.fontComboBox.currentFont().family())
|
||||
self.parent.settings.set('font_family', self.parent.font_family)
|
||||
self.parent.font_size = int(self.parent.configpage.ui.spinBox_fontSize.value())
|
||||
self.parent.settings.set('font_size', self.parent.font_size)
|
||||
self.parent.font_color = str(self.parent.configpage.ui.kcolorcombo.color().name())
|
||||
self.parent.settings.set('font_color', self.parent.font_color)
|
||||
if (self.parent.configpage.ui.comboBox_style.currentIndex() == 0):
|
||||
self.parent.font_style = 'normal'
|
||||
else:
|
||||
self.parent.font_style = 'italic'
|
||||
self.parent.settings.set('font_style', self.parent.font_style)
|
||||
self.parent.font_weight = int(self.parent.configpage.ui.spinBox_weight.value())
|
||||
self.parent.settings.set('font_weight', self.parent.font_weight)
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
if (self.parent.uptimeBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("system/uptime", self.parent)
|
||||
self.parent.label_uptime.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_uptime)
|
||||
if (self.parent.cpuBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/system/TotalLoad", self.parent)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
self.parent.label_cpu0.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpu0)
|
||||
self.parent.label_cpu1.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpu1)
|
||||
for core in range(self.parent.numCores):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent)
|
||||
exec ("self.parent.label_coreCpu" + str(core) + ".setText('')")
|
||||
exec ("self.parent.layout.removeItem(self.parent.label_coreCpu" + str(core) + ")")
|
||||
else:
|
||||
self.parent.label_cpu.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpu)
|
||||
if (self.parent.cpuclockBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/system/AverageClock", self.parent)
|
||||
if (self.parent.cpuclockFormat.split('$ccpu')[0] != self.parent.cpuclockFormat):
|
||||
self.parent.label_cpuclock0.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpuclock0)
|
||||
self.parent.label_cpuclock1.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpuclock1)
|
||||
for core in range(self.parent.numCores):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self.parent)
|
||||
exec ("self.parent.label_coreCpuclock" + str(core) + ".setText('')")
|
||||
exec ("self.parent.layout.removeItem(self.parent.label_coreCpuclock" + str(core) + ")")
|
||||
else:
|
||||
self.parent.label_cpuclock.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpuclock)
|
||||
if (self.parent.tempBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource(self.parent.tempdev, self.parent)
|
||||
self.parent.label_temp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_temp)
|
||||
if (self.parent.gpuBool == 1):
|
||||
self.parent.gpuChecker.stop()
|
||||
self.parent.label_gpu.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_gpu)
|
||||
if (self.parent.gputempBool == 1):
|
||||
self.parent.gpuTempChecker.stop()
|
||||
self.parent.label_gputemp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_gputemp)
|
||||
if (self.parent.memBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("mem/physical/application", self.parent)
|
||||
if (self.parent.memInMb == False):
|
||||
self.parent.systemmonitor.disconnectSource("mem/physical/free", self.parent)
|
||||
self.parent.systemmonitor.disconnectSource("mem/physical/used", self.parent)
|
||||
self.parent.label_mem.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_mem)
|
||||
if (self.parent.swapBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("mem/swap/used", self.parent)
|
||||
if (self.parent.swapInMb == False):
|
||||
self.parent.systemmonitor.disconnectSource("mem/swap/free", self.parent)
|
||||
self.parent.label_swap.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_swap)
|
||||
if (self.parent.hddBool == 1):
|
||||
for mount in self.parent.mountPoints:
|
||||
self.parent.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self.parent)
|
||||
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText("")')
|
||||
exec ("self.parent.layout.removeItem(self.parent.label_hdd_" + ''.join(mount.split('/')) + ")")
|
||||
self.parent.label_hdd0.setText('')
|
||||
self.parent.label_hdd1.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_hdd0)
|
||||
self.parent.layout.removeItem(self.parent.label_hdd1)
|
||||
if (self.parent.hddtempBool == 1):
|
||||
self.parent.hddTempChecker.stop()
|
||||
self.parent.label_hddtemp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_hddtemp)
|
||||
if (self.parent.netBool == 1):
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
|
||||
self.parent.label_netDown.setText('')
|
||||
self.parent.label_netUp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_netUp)
|
||||
self.parent.layout.removeItem(self.parent.label_netDown)
|
||||
if (self.parent.batBool == 1):
|
||||
self.parent.label_bat.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_bat)
|
||||
|
||||
self.parent.label_order = "------------"
|
||||
|
||||
for label in self.parent.dict_orders.keys():
|
||||
if (self.parent.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2):
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 1')
|
||||
pos = self.parent.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:]
|
||||
else:
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 0')
|
||||
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.settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
|
||||
else:
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.parent.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 ('self.parent.settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||
if (self.parent.dict_orders[label] == 'net'):
|
||||
self.parent.num_dev = int(self.parent.configpage.ui.comboBox_numNet.currentIndex())
|
||||
self.parent.settings.set('num_dev', self.parent.num_dev)
|
||||
elif (self.parent.dict_orders[label] == 'bat'):
|
||||
self.parent.battery_device = str(self.parent.configpage.ui.lineEdit_batdev.text())
|
||||
self.parent.ac_device = str(self.parent.configpage.ui.lineEdit_acdev.text())
|
||||
self.parent.settings.set('battery_device', self.parent.battery_device)
|
||||
self.parent.settings.set('ac_device', self.parent.ac_device)
|
||||
|
||||
self.parent.label_order = ''.join(self.parent.label_order.split('-'))
|
||||
self.parent.settings.set('label_order', self.parent.label_order)
|
||||
|
||||
# reinitializate
|
||||
self.parent.reinit.reinit()
|
195
source/contents/code/dataengine.py
Normal file
195
source/contents/code/dataengine.py
Normal file
@ -0,0 +1,195 @@
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
from PyKDE4 import plasmascript
|
||||
|
||||
|
||||
|
||||
class DataEngine:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def connectToEngine(self):
|
||||
"""function to initializate engine"""
|
||||
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
|
||||
if (self.parent.uptimeBool == 1):
|
||||
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuBool == 1):
|
||||
self.parent.systemmonitor.connectSource("cpu/system/TotalLoad", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
for core in range(self.parent.numCores):
|
||||
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuclockBool == 1):
|
||||
self.parent.systemmonitor.connectSource("cpu/system/AverageClock", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
for core in range(self.parent.numCores):
|
||||
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):
|
||||
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
|
||||
if (self.parent.memBool == 1):
|
||||
if (self.parent.memInMb):
|
||||
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval)
|
||||
else:
|
||||
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, 200)
|
||||
if (self.parent.swapBool == 1):
|
||||
if (self.parent.swapInMb):
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval)
|
||||
else:
|
||||
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, 200)
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, 200)
|
||||
if (self.parent.hddBool == 1):
|
||||
for mount in self.parent.mountPoints:
|
||||
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
|
||||
|
||||
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to refresh data"""
|
||||
if (sourceName == "system/uptime"):
|
||||
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)
|
||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
||||
line = self.parent.uptimeFormat.split('$uptime')[0] + uptimeText + self.parent.uptimeFormat.split('$uptime')[1]
|
||||
else:
|
||||
line = self.parent.uptimeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_uptime.setText(text)
|
||||
elif (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu0.setText(text)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu1.setText(text)
|
||||
else:
|
||||
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
|
||||
line = self.parent.cpuFormat.split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "TotalLoad")):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpu' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock0.setText(text)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock1.setText(text)
|
||||
else:
|
||||
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
|
||||
line = self.parent.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "clock")):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + cpuclockText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
up_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = '/' + up_speed + self.parent.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netUp.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/receiver/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
down_speed = "%4s" % (value)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = self.parent.netFormat.split('$net')[0] + down_speed
|
||||
else:
|
||||
line = self.parent.netFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netDown.setText(text)
|
||||
# update network device
|
||||
self.parent.updateNetdev = self.parent.updateNetdev + 1
|
||||
if (self.parent.updateNetdev == 100):
|
||||
self.parent.updateNetdev = 0
|
||||
if (self.parent.netNonFormat.split('@@')[0] == self.parent.netNonFormat):
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
|
||||
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
|
||||
self.parent.setupNetdev()
|
||||
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.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]
|
||||
else:
|
||||
self.parent.netFormat = self.parent.netNonFormat
|
||||
elif (sourceName == self.parent.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
tempText = "%4s" % (value)
|
||||
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
|
||||
line = self.parent.tempFormat.split('$temp')[0] + tempText + self.parent.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.parent.tempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_temp.setText(text)
|
||||
elif (str(sourceName).split('/')[0] == "partitions"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
hddText = "%5s" % (value)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + hddText + self.parent.formatLine.split('$LINE')[1]
|
||||
exec ('self.parent.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)')
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.parent.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
self.parent.mem_uf = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
if (self.parent.memInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
|
||||
line = self.parent.memFormat.split('$memmb')[0] + mem + self.parent.memFormat.split('$memmb')[1]
|
||||
else:
|
||||
line = self.parent.memFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_mem.setText(text)
|
||||
else:
|
||||
self.parent.mem_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
self.parent.swap_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
if (self.parent.swapInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
|
||||
line = self.parent.swapFormat.split('$swapmb')[0] + mem + self.parent.swapFormat.split('$swapmb')[1]
|
||||
else:
|
||||
line = self.parent.swapFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_swap.setText(text)
|
||||
else:
|
||||
self.parent.swap_used = float(data[QString(u'value')])
|
38
source/contents/code/gpuchecker.py
Normal file
38
source/contents/code/gpuchecker.py
Normal file
@ -0,0 +1,38 @@
|
||||
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
|
35
source/contents/code/gputempchecker.py
Normal file
35
source/contents/code/gputempchecker.py
Normal file
@ -0,0 +1,35 @@
|
||||
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
|
29
source/contents/code/hddtempchecker.py
Normal file
29
source/contents/code/hddtempchecker.py
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
@ -5,14 +5,15 @@ from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
from PyKDE4.kio import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
from PyKDE4 import plasmascript
|
||||
from PyQt4 import QtCore
|
||||
from configwindow import *
|
||||
from config import *
|
||||
from util import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
import commands, os, time
|
||||
|
||||
import configaccepted
|
||||
import configwindow
|
||||
import dataengine
|
||||
import reinit
|
||||
|
||||
|
||||
|
||||
class pyTextWidget(plasmascript.Applet):
|
||||
@ -25,144 +26,17 @@ class pyTextWidget(plasmascript.Applet):
|
||||
"""function to initializate widget"""
|
||||
self._name = str(self.package().metadata().pluginName())
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
self.configAccepted = configaccepted.ConfigAccepted(self)
|
||||
self.dataengine = dataengine.DataEngine(self)
|
||||
self.reinit = reinit.Reinit(self)
|
||||
self.setupVar()
|
||||
self.reinit()
|
||||
self.reinit.reinit()
|
||||
self.setHasConfigurationInterface(True)
|
||||
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
# update local variables
|
||||
self.interval = int(self.configpage.ui.spinBox_interval.value())
|
||||
self.settings.set('interval', self.interval)
|
||||
self.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
|
||||
self.settings.set('font_family', self.font_family)
|
||||
self.font_size = int(self.configpage.ui.spinBox_fontSize.value())
|
||||
self.settings.set('font_size', self.font_size)
|
||||
self.font_color = str(self.configpage.ui.kcolorcombo.color().name())
|
||||
self.settings.set('font_color', self.font_color)
|
||||
if (self.configpage.ui.comboBox_style.currentIndex() == 0):
|
||||
self.font_style = 'normal'
|
||||
else:
|
||||
self.font_style = 'italic'
|
||||
self.settings.set('font_style', self.font_style)
|
||||
self.font_weight = int(self.configpage.ui.spinBox_weight.value())
|
||||
self.settings.set('font_weight', self.font_weight)
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
if (self.uptimeBool == 1):
|
||||
self.systemmonitor.disconnectSource("system/uptime", self)
|
||||
self.label_uptime.setText('')
|
||||
self.layout.removeItem(self.label_uptime)
|
||||
if (self.cpuBool == 1):
|
||||
self.systemmonitor.disconnectSource("cpu/system/TotalLoad", self)
|
||||
if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat):
|
||||
self.label_cpu0.setText('')
|
||||
self.layout.removeItem(self.label_cpu0)
|
||||
self.label_cpu1.setText('')
|
||||
self.layout.removeItem(self.label_cpu1)
|
||||
for core in range(self.numCores):
|
||||
self.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self)
|
||||
exec ("self.label_coreCpu" + str(core) + ".setText('')")
|
||||
exec ("self.layout.removeItem(self.label_coreCpu" + str(core) + ")")
|
||||
else:
|
||||
self.label_cpu.setText('')
|
||||
self.layout.removeItem(self.label_cpu)
|
||||
if (self.cpuclockBool == 1):
|
||||
self.systemmonitor.disconnectSource("cpu/system/AverageClock", self)
|
||||
if (self.cpuclockFormat.split('$ccpu')[0] != self.cpuclockFormat):
|
||||
self.label_cpuclock0.setText('')
|
||||
self.layout.removeItem(self.label_cpuclock0)
|
||||
self.label_cpuclock1.setText('')
|
||||
self.layout.removeItem(self.label_cpuclock1)
|
||||
for core in range(self.numCores):
|
||||
self.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self)
|
||||
exec ("self.label_coreCpuclock" + str(core) + ".setText('')")
|
||||
exec ("self.layout.removeItem(self.label_coreCpuclock" + str(core) + ")")
|
||||
else:
|
||||
self.label_cpuclock.setText('')
|
||||
self.layout.removeItem(self.label_cpuclock)
|
||||
if (self.tempBool == 1):
|
||||
self.systemmonitor.disconnectSource(self.tempdev, self)
|
||||
self.label_temp.setText('')
|
||||
self.layout.removeItem(self.label_temp)
|
||||
if (self.gpuBool == 1):
|
||||
self.label_gpu.setText('')
|
||||
self.layout.removeItem(self.label_gpu)
|
||||
if (self.gputempBool == 1):
|
||||
self.label_gputemp.setText('')
|
||||
self.layout.removeItem(self.label_gputemp)
|
||||
if (self.memBool == 1):
|
||||
self.systemmonitor.disconnectSource("mem/physical/application", self)
|
||||
if (self.memInMb == False):
|
||||
self.systemmonitor.disconnectSource("mem/physical/free", self)
|
||||
self.systemmonitor.disconnectSource("mem/physical/used", self)
|
||||
self.label_mem.setText('')
|
||||
self.layout.removeItem(self.label_mem)
|
||||
if (self.swapBool == 1):
|
||||
self.systemmonitor.disconnectSource("mem/swap/used", self)
|
||||
if (self.swapInMb == False):
|
||||
self.systemmonitor.disconnectSource("mem/swap/free", self)
|
||||
self.label_swap.setText('')
|
||||
self.layout.removeItem(self.label_swap)
|
||||
if (self.hddBool == 1):
|
||||
for mount in self.mountPoints:
|
||||
self.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self)
|
||||
exec ('self.label_hdd_' + ''.join(mount.split('/')) + '.setText("")')
|
||||
exec ("self.layout.removeItem(self.label_hdd_" + ''.join(mount.split('/')) + ")")
|
||||
self.label_hdd0.setText('')
|
||||
self.label_hdd1.setText('')
|
||||
self.layout.removeItem(self.label_hdd0)
|
||||
self.layout.removeItem(self.label_hdd1)
|
||||
if (self.hddtempBool == 1):
|
||||
self.label_hddtemp.setText('')
|
||||
self.layout.removeItem(self.label_hddtemp)
|
||||
if (self.netBool == 1):
|
||||
self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/transmitter/data", self)
|
||||
self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/receiver/data", self)
|
||||
self.label_netDown.setText('')
|
||||
self.label_netUp.setText('')
|
||||
self.layout.removeItem(self.label_netUp)
|
||||
self.layout.removeItem(self.label_netDown)
|
||||
if (self.batBool == 1):
|
||||
self.label_bat.setText('')
|
||||
self.layout.removeItem(self.label_bat)
|
||||
|
||||
self.label_order = "------------"
|
||||
|
||||
for label in self.dict_orders.keys():
|
||||
if (self.configpage.checkboxes[self.dict_orders[label]].checkState() == 2):
|
||||
exec ('self.' + self.dict_orders[label] + 'Bool = 1')
|
||||
pos = self.configpage.sliders[self.dict_orders[label]].value() - 1
|
||||
self.label_order = self.label_order[:pos] + label + self.label_order[pos+1:]
|
||||
else:
|
||||
exec ('self.' + self.dict_orders[label] + 'Bool = 0')
|
||||
if (self.dict_orders[label] == 'net'):
|
||||
exec ('self.' + self.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.dict_orders[label]].text())')
|
||||
exec ('self.settings.set("' + self.dict_orders[label] + 'NonFormat", self.' + self.dict_orders[label] + 'NonFormat)')
|
||||
else:
|
||||
exec ('self.' + self.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.dict_orders[label]].text())')
|
||||
exec ('self.settings.set("' + self.dict_orders[label] + 'Format", self.' + self.dict_orders[label] + 'Format)')
|
||||
exec ('self.settings.set("' + self.dict_orders[label] + 'Bool", self.' + self.dict_orders[label] + 'Bool)')
|
||||
if (self.dict_orders[label] == 'net'):
|
||||
self.num_dev = int(self.configpage.ui.comboBox_numNet.currentIndex())
|
||||
self.settings.set('num_dev', self.num_dev)
|
||||
elif (self.dict_orders[label] == 'bat'):
|
||||
self.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||
self.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||
self.settings.set('battery_device', self.battery_device)
|
||||
self.settings.set('ac_device', self.ac_device)
|
||||
|
||||
self.label_order = ''.join(self.label_order.split('-'))
|
||||
self.settings.set('label_order', self.label_order)
|
||||
|
||||
# reinitializate
|
||||
self.reinit()
|
||||
|
||||
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
self.configpage = ConfigWindow(self, self.settings)
|
||||
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)))
|
||||
@ -195,280 +69,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
page = parent.addPage(self.configpage, i18n(self.name()))
|
||||
page.setIcon(KIcon(self.icon()))
|
||||
|
||||
parent.okClicked.connect(self.configAccepted)
|
||||
|
||||
|
||||
def reinit(self):
|
||||
"""function to reinitializate widget"""
|
||||
self.settings = Config(self)
|
||||
self.interval = int(self.settings.get('interval', 2000))
|
||||
self.font_family = str(self.settings.get('font_family', 'Terminus'))
|
||||
self.font_size = int(self.settings.get('font_size', 12))
|
||||
self.font_color = str(self.settings.get('font_color', '#000000'))
|
||||
self.font_style = str(self.settings.get('font_style', 'normal'))
|
||||
self.font_weight = int(self.settings.get('font_weight', 400))
|
||||
self.formatLine = "<pre><p align=\"center\"><span style=\" font-family:'" + self.font_family + "'; font-style:" + self.font_style
|
||||
self.formatLine = self.formatLine + "; font-size:" + str(self.font_size) + "pt; font-weight:" + str(self.font_weight)
|
||||
self.formatLine = self.formatLine + "; color:" + self.font_color + ";\">$LINE</span></p></pre>"
|
||||
self.label_order = str(self.settings.get('label_order', '1345'))
|
||||
for label in self.dict_orders.values():
|
||||
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
|
||||
exec ('self.' + label + 'Bool = int(self.settings.get("' + label + 'Bool", 1))')
|
||||
else:
|
||||
exec ('self.' + label + 'Bool = int(self.settings.get("' + label + 'Bool", 0))')
|
||||
# small function for update if errors exist
|
||||
summ = 0
|
||||
for label in self.dict_orders.values():
|
||||
exec ('summ += self.' + label + 'Bool')
|
||||
if (len(self.label_order) != summ):
|
||||
for label in self.dict_orders.values():
|
||||
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
|
||||
exec ('self.' + label + 'Bool = 1')
|
||||
else:
|
||||
exec ('self.' + label + 'Bool = 0')
|
||||
exec ('self.settings.set("' + label + 'Bool", self.' + label + 'Bool)')
|
||||
self.label_order = '1345'
|
||||
self.settings.set('label_order', self.label_order)
|
||||
|
||||
for order in self.label_order:
|
||||
if (order == "1"):
|
||||
if (self.cpuBool == 1):
|
||||
self.cpuFormat = str(self.settings.get('cpuFormat', '[cpu: $cpu%]'))
|
||||
if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat):
|
||||
self.label_cpu0 = Plasma.Label(self.applet)
|
||||
self.label_cpu1 = Plasma.Label(self.applet)
|
||||
if (self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + '-----' + self.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat.split('$ccpu')[0]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu0.setText(text)
|
||||
self.layout.addItem(self.label_cpu0)
|
||||
text = self.formatLine.split('$LINE')[0] + "-----" + self.formatLine.split('$LINE')[1]
|
||||
for core in range(self.numCores):
|
||||
#text = self.formatLine.split('$LINE')[0] + "Core" + str(core) + "\n-----" + self.formatLine.split('$LINE')[1]
|
||||
exec ('self.label_coreCpu' + str(core) + ' = Plasma.Label(self.applet)')
|
||||
exec ('self.label_coreCpu' + str(core) + '.setText(text)')
|
||||
exec ('self.layout.addItem(self.label_coreCpu' + str(core) + ')')
|
||||
if (self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + '-----' + self.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat.split('$ccpu')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu1.setText(text)
|
||||
self.layout.addItem(self.label_cpu1)
|
||||
else:
|
||||
self.label_cpu = Plasma.Label(self.applet)
|
||||
if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat):
|
||||
line = self.cpuFormat.split('$cpu')[0] + '-----' + self.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu.setText(text)
|
||||
self.layout.addItem(self.label_cpu)
|
||||
elif (order == "2"):
|
||||
if (self.tempBool == 1):
|
||||
self.tempFormat = str(self.settings.get('tempFormat', '[temp: $temp°C]'))
|
||||
self.label_temp = Plasma.Label(self.applet)
|
||||
if (self.tempFormat.split('$temp')[0] != self.tempFormat):
|
||||
line = self.tempFormat.split('$temp')[0] + '----' + self.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.tempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_temp.setText(text)
|
||||
self.layout.addItem(self.label_temp)
|
||||
elif (order == "3"):
|
||||
if (self.memBool == 1):
|
||||
self.memFormat = str(self.settings.get('memFormat', '[mem: $mem%]'))
|
||||
if (self.memFormat.split('$memmb')[0] != self.memFormat):
|
||||
self.memInMb = True
|
||||
text = self.formatLine.split('$LINE')[0] + self.memFormat.split('$memmb')[0] + '-----' + self.memFormat.split('$memmb')[1] + self.formatLine.split('$LINE')[1]
|
||||
elif (self.memFormat.split('$mem')[0] != self.memFormat):
|
||||
self.memInMb = False
|
||||
self.mem_used = 0.0
|
||||
self.mem_free = 1.0
|
||||
self.mem_uf = 0.0
|
||||
line = self.memFormat.split('$mem')[0] + '-----' + self.memFormat.split('$mem')[1]
|
||||
else:
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem = Plasma.Label(self.applet)
|
||||
self.label_mem.setText(text)
|
||||
self.layout.addItem(self.label_mem)
|
||||
elif (order == "4"):
|
||||
if (self.swapBool == 1):
|
||||
self.swapFormat = str(self.settings.get('swapFormat', '[swap: $swap%]'))
|
||||
if (self.swapFormat.split('$swapmb')[0] != self.swapFormat):
|
||||
self.swapInMb = True
|
||||
text = self.formatLine.split('$LINE')[0] + self.swapFormat.split('$swapmb')[0] + '-----' + self.swapFormat.split('$swapmb')[1] + self.formatLine.split('$LINE')[1]
|
||||
elif (self.swapFormat.split('$swap')[0] != self.swapFormat):
|
||||
self.swapInMb = False
|
||||
self.swap_free = 1.0
|
||||
self.swap_used = 0.0
|
||||
line = self.swapFormat.split('$swap')[0] + '-----' + self.swapFormat.split('$swap')[1]
|
||||
else:
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap = Plasma.Label(self.applet)
|
||||
self.label_swap.setText(text)
|
||||
self.layout.addItem(self.label_swap)
|
||||
elif (order == "5"):
|
||||
if (self.netBool == 1):
|
||||
self.netNonFormat = str(self.settings.get('netNonFormat', '[net: $netKB/s]'))
|
||||
if (self.netNonFormat.split('@@')[0] != self.netNonFormat):
|
||||
self.netdev = self.netNonFormat.split('@@')[1]
|
||||
self.netNonFormat = self.netNonFormat.split('@@')[0] + self.netNonFormat.split('@@')[2]
|
||||
else:
|
||||
self.num_dev = int(self.settings.get('num_dev', 0))
|
||||
self.setupNetdev()
|
||||
if (self.netNonFormat.split('$netdev')[0] != self.netNonFormat):
|
||||
self.netFormat = self.netNonFormat.split('$netdev')[0] + self.netdev + self.netNonFormat.split('$netdev')[1]
|
||||
else:
|
||||
self.netFormat = self.netNonFormat
|
||||
self.label_netDown = Plasma.Label(self.applet)
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = self.netFormat.split('$net')[0] + '----'
|
||||
else:
|
||||
line = self.netFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netDown.setText(text)
|
||||
self.layout.addItem(self.label_netDown)
|
||||
self.label_netUp = Plasma.Label(self.applet)
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = '/----' + self.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netUp.setText(text)
|
||||
self.layout.addItem(self.label_netUp)
|
||||
elif (order == "6"):
|
||||
if (self.batBool == 1):
|
||||
self.batFormat = str(self.settings.get('batFormat', '[bat: $bat%$ac]'))
|
||||
self.battery_device= str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.ac_device = str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.label_bat = Plasma.Label(self.applet)
|
||||
line = self.batFormat
|
||||
if (line.split('$ac')[0] != line):
|
||||
line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1]
|
||||
if (line.split('$bat')[0] != line):
|
||||
line = line.split('$bat')[0] + '---' + line.split('$bat')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_bat.setText(text)
|
||||
self.layout.addItem(self.label_bat)
|
||||
elif (order == "7"):
|
||||
if (self.cpuclockBool == 1):
|
||||
self.cpuclockFormat = str(self.settings.get('cpuclockFormat', '[mhz: $cpucl]'))
|
||||
if (self.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat):
|
||||
self.label_cpuclock0 = Plasma.Label(self.applet)
|
||||
self.label_cpuclock1 = Plasma.Label(self.applet)
|
||||
if (self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat.split('$ccpucl')[0]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock0.setText(text)
|
||||
self.layout.addItem(self.label_cpuclock0)
|
||||
text = self.formatLine.split('$LINE')[0] + "----" + self.formatLine.split('$LINE')[1]
|
||||
for core in range(self.numCores):
|
||||
exec ('self.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.applet)')
|
||||
exec ('self.label_coreCpuclock' + str(core) + '.setText(text)')
|
||||
exec ('self.layout.addItem(self.label_coreCpuclock' + str(core) + ')')
|
||||
if (self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat.split('$ccpucl')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock1.setText(text)
|
||||
self.layout.addItem(self.label_cpuclock1)
|
||||
else:
|
||||
self.label_cpuclock = Plasma.Label(self.applet)
|
||||
if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat):
|
||||
line = self.cpuclockFormat.split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock.setText(text)
|
||||
self.layout.addItem(self.label_cpuclock)
|
||||
elif (order == "8"):
|
||||
if (self.uptimeBool == 1):
|
||||
self.uptimeFormat = str(self.settings.get('uptimeFormat', '[uptime: $uptime]'))
|
||||
self.label_uptime = Plasma.Label(self.applet)
|
||||
if (self.uptimeFormat.split('$uptime')[0] != self.uptimeFormat):
|
||||
line = self.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.uptimeFormat.split('$uptime')[1]
|
||||
else:
|
||||
line = self.uptimeFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_uptime.setText(text)
|
||||
self.layout.addItem(self.label_uptime)
|
||||
elif (order == "9"):
|
||||
if (self.gpuBool == 1):
|
||||
self.gpuFormat = str(self.settings.get('gpuFormat', '[gpu: $gpu%]'))
|
||||
self.label_gpu = Plasma.Label(self.applet)
|
||||
if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat):
|
||||
line = self.gpuFormat.split('$gpu')[0] + '-----' + 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)
|
||||
self.layout.addItem(self.label_gpu)
|
||||
elif (order == "a"):
|
||||
if (self.gputempBool == 1):
|
||||
self.gputempFormat = str(self.settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
||||
self.label_gputemp = Plasma.Label(self.applet)
|
||||
if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat):
|
||||
line = self.gputempFormat.split('$gputemp')[0] + '----' + 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)
|
||||
self.layout.addItem(self.label_gputemp)
|
||||
elif (order == "b"):
|
||||
if (self.hddBool == 1):
|
||||
self.hddFormat = str(self.settings.get('hddFormat', '[hdd: @@/@@%]'))
|
||||
if (self.hddFormat.split('@@')[0] != self.hddFormat):
|
||||
self.mountPoints = self.hddFormat.split('@@')[1].split(';')
|
||||
line = self.hddFormat.split('@@')[0]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_hdd0 = Plasma.Label(self.applet)
|
||||
self.label_hdd0.setText(text)
|
||||
self.layout.addItem(self.label_hdd0)
|
||||
text = self.formatLine.split('$LINE')[0] + "-----" + self.formatLine.split('$LINE')[1]
|
||||
for mount in self.mountPoints:
|
||||
exec ('self.label_hdd_' + ''.join(mount.split('/')) + ' = Plasma.Label(self.applet)')
|
||||
exec ('self.label_hdd_' + ''.join(mount.split('/')) + '.setText(text)')
|
||||
exec ('self.layout.addItem(self.label_hdd_' + ''.join(mount.split('/')) + ')')
|
||||
line = self.hddFormat.split('@@')[2]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_hdd1 = Plasma.Label(self.applet)
|
||||
self.label_hdd1.setText(text)
|
||||
self.layout.addItem(self.label_hdd1)
|
||||
else:
|
||||
line = self.hddFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_hdd0.setText(text)
|
||||
self.layout.addItem(self.label_hdd0)
|
||||
elif (order == "c"):
|
||||
if (self.hddtempBool == 1):
|
||||
self.hddtempFormat = str(self.settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]'))
|
||||
self.label_hddtemp = Plasma.Label(self.applet)
|
||||
if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat):
|
||||
line = self.hddtempFormat.split('@@')[0] + '----' + 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)
|
||||
self.layout.addItem(self.label_hddtemp)
|
||||
self.applet.setLayout(self.layout)
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
self.resize(10,10)
|
||||
|
||||
# start timer
|
||||
self.connectToEngine()
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(self.interval)
|
||||
self.startPolling()
|
||||
parent.okClicked.connect(self.configAccepted.configAccepted)
|
||||
|
||||
|
||||
def setupNetdev(self):
|
||||
@ -535,7 +136,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
def startPolling(self):
|
||||
try:
|
||||
self.timer.start()
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.updateLabel)
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
|
||||
self.updateLabel()
|
||||
self.showTooltip('')
|
||||
except Exception as (strerror):
|
||||
@ -549,14 +150,17 @@ class pyTextWidget(plasmascript.Applet):
|
||||
"""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()
|
||||
|
||||
@ -590,19 +194,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def gpuText(self):
|
||||
"""function to set gpu text"""
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||
if (commandOut.split()[2] == 'N/A'):
|
||||
gpu = ' N/A'
|
||||
else:
|
||||
gpu = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1)))
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||
gpu = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1)))
|
||||
else:
|
||||
gpu = '-----'
|
||||
if (self.gpuFormat.split('$gpu')[0] != self.gpuFormat):
|
||||
line = self.gpuFormat.split('$gpu')[0] + gpu + self.gpuFormat.split('$gpu')[1]
|
||||
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]
|
||||
@ -611,16 +204,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def gputempText(self):
|
||||
"""function to set gpu temperature text"""
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||
gputemp = "%4s" % (str(round(float(commandOut.split()[2]), 1)))
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||
gputemp = "%4s" % (str(round(float(commandOut.split()[4]), 1)))
|
||||
else:
|
||||
gputemp = '----'
|
||||
if (self.gputempFormat.split('$gputemp')[0] != self.gputempFormat):
|
||||
line = self.gputempFormat.split('$gputemp')[0] + gputemp + self.gputempFormat.split('$gputemp')[1]
|
||||
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]
|
||||
@ -629,10 +214,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def hddtempText(self):
|
||||
"""function to set hdd temperature text"""
|
||||
commandOut = commands.getoutput("hddtemp "+self.hddtempFormat.split('@@')[1])
|
||||
hddtemp = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1)))
|
||||
if (self.hddtempFormat.split('@@')[0] != self.hddtempFormat):
|
||||
line = self.hddtempFormat.split('@@')[0] + hddtemp + self.hddtempFormat.split('@@')[2]
|
||||
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]
|
||||
@ -663,191 +246,12 @@ class pyTextWidget(plasmascript.Applet):
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap.setText(text)
|
||||
|
||||
|
||||
def connectToEngine(self):
|
||||
"""function to initializate engine"""
|
||||
self.systemmonitor = self.dataEngine("systemmonitor")
|
||||
if (self.uptimeBool == 1):
|
||||
self.systemmonitor.connectSource("system/uptime", self, self.interval)
|
||||
if (self.cpuBool == 1):
|
||||
self.systemmonitor.connectSource("cpu/system/TotalLoad", self, self.interval)
|
||||
if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat):
|
||||
for core in range(self.numCores):
|
||||
self.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self, self.interval)
|
||||
if (self.cpuclockBool == 1):
|
||||
self.systemmonitor.connectSource("cpu/system/AverageClock", self, self.interval)
|
||||
if (self.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat):
|
||||
for core in range(self.numCores):
|
||||
self.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self, self.interval)
|
||||
if (self.netBool == 1):
|
||||
self.updateNetdev = 0
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/transmitter/data", self, self.interval)
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/receiver/data", self, self.interval)
|
||||
if (self.tempBool == 1):
|
||||
self.systemmonitor.connectSource(self.tempdev, self, self.interval)
|
||||
if (self.memBool == 1):
|
||||
if (self.memInMb):
|
||||
self.systemmonitor.connectSource("mem/physical/application", self, self.interval)
|
||||
else:
|
||||
self.systemmonitor.connectSource("mem/physical/free", self, 200)
|
||||
self.systemmonitor.connectSource("mem/physical/used", self, 200)
|
||||
self.systemmonitor.connectSource("mem/physical/application", self, 200)
|
||||
if (self.swapBool == 1):
|
||||
if (self.swapInMb):
|
||||
self.systemmonitor.connectSource("mem/swap/used", self, self.interval)
|
||||
else:
|
||||
self.systemmonitor.connectSource("mem/swap/free", self, 200)
|
||||
self.systemmonitor.connectSource("mem/swap/used", self, 200)
|
||||
if (self.hddBool == 1):
|
||||
for mount in self.mountPoints:
|
||||
self.systemmonitor.connectSource("partitions" + mount + "/filllevel", self, self.interval)
|
||||
|
||||
|
||||
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to refresh data"""
|
||||
if (sourceName == "system/uptime"):
|
||||
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)
|
||||
if (self.uptimeFormat.split('$uptime')[0] != self.uptimeFormat):
|
||||
line = self.uptimeFormat.split('$uptime')[0] + uptimeText + self.uptimeFormat.split('$uptime')[1]
|
||||
else:
|
||||
line = self.uptimeFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_uptime.setText(text)
|
||||
elif (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
if (self.cpuFormat.split('$ccpu')[0] != self.cpuFormat):
|
||||
if (self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat.split('$ccpu')[0]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu0.setText(text)
|
||||
if (self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat.split('$ccpu')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu1.setText(text)
|
||||
else:
|
||||
if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat):
|
||||
line = self.cpuFormat.split('$cpu')[0] + cpuText + self.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "TotalLoad")):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
text = self.formatLine.split('$LINE')[0] + cpuText + self.formatLine.split('$LINE')[1]
|
||||
#text = self.formatLine.split('$LINE')[0] + "Core" + str(sourceName)[7] + "\n" + cpuText + self.formatLine.split('$LINE')[1]
|
||||
exec ('self.label_coreCpu' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
if (self.cpuclockFormat.split('$ccpucl')[0] != self.cpuclockFormat):
|
||||
if (self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat.split('$ccpucl')[0]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock0.setText(text)
|
||||
if (self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat.split('$ccpucl')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock1.setText(text)
|
||||
else:
|
||||
if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat):
|
||||
line = self.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock.setText(text)
|
||||
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "clock")):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
text = self.formatLine.split('$LINE')[0] + cpuclockText + self.formatLine.split('$LINE')[1]
|
||||
exec ('self.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)')
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
up_speed = "%4s" % (value)
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = '/' + up_speed + self.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netUp.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/receiver/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
down_speed = "%4s" % (value)
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = self.netFormat.split('$net')[0] + down_speed
|
||||
else:
|
||||
line = self.netFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netDown.setText(text)
|
||||
# update network device
|
||||
self.updateNetdev = self.updateNetdev + 1
|
||||
if (self.updateNetdev == 100):
|
||||
self.updateNetdev = 0
|
||||
if (self.netNonFormat.split('@@')[0] == self.netNonFormat):
|
||||
self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/transmitter/data", self)
|
||||
self.systemmonitor.disconnectSource("network/interfaces/"+self.netdev+"/receiver/data", self)
|
||||
self.setupNetdev()
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/transmitter/data", self, self.interval)
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/receiver/data", self, self.interval)
|
||||
if (self.netNonFormat.split('$netdev')[0] != self.netNonFormat):
|
||||
self.netFormat = self.netNonFormat.split('$netdev')[0] + self.netdev + self.netNonFormat.split('$netdev')[1]
|
||||
else:
|
||||
self.netFormat = self.netNonFormat
|
||||
elif (sourceName == self.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
tempText = "%4s" % (value)
|
||||
if (self.tempFormat.split('$temp')[0] != self.tempFormat):
|
||||
line = self.tempFormat.split('$temp')[0] + tempText + self.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.tempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_temp.setText(text)
|
||||
elif (str(sourceName).split('/')[0] == "partitions"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
hddText = "%5s" % (value)
|
||||
text = self.formatLine.split('$LINE')[0] + hddText + self.formatLine.split('$LINE')[1]
|
||||
exec ('self.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)')
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
self.mem_uf = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
if (self.memInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.memFormat.split('$memmb')[0] != self.memFormat):
|
||||
line = self.memFormat.split('$memmb')[0] + mem + self.memFormat.split('$memmb')[1]
|
||||
else:
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem.setText(text)
|
||||
else:
|
||||
self.mem_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
self.swap_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
if (self.swapInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
if (self.swapFormat.split('$swapmb')[0] != self.swapFormat):
|
||||
line = self.swapFormat.split('$swapmb')[0] + mem + self.swapFormat.split('$swapmb')[1]
|
||||
else:
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap.setText(text)
|
||||
else:
|
||||
self.swap_used = float(data[QString(u'value')])
|
||||
"""function to update label"""
|
||||
self.dataengine.dataUpdated(sourceName, data)
|
||||
|
||||
|
||||
|
||||
|
293
source/contents/code/reinit.py
Normal file
293
source/contents/code/reinit.py
Normal file
@ -0,0 +1,293 @@
|
||||
from PyQt4.QtCore import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
import config
|
||||
import gpuchecker
|
||||
import gputempchecker
|
||||
import hddtempchecker
|
||||
|
||||
|
||||
|
||||
class Reinit():
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
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))
|
||||
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 + "; color:" + self.parent.font_color + ";\">$LINE</span></p></pre>"
|
||||
self.parent.label_order = str(self.parent.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))')
|
||||
else:
|
||||
exec ('self.parent.' + label + 'Bool = int(self.parent.settings.get("' + label + 'Bool", 0))')
|
||||
# small function for update if errors exist
|
||||
summ = 0
|
||||
for label in self.parent.dict_orders.values():
|
||||
exec ('summ += self.parent.' + label + 'Bool')
|
||||
if (len(self.parent.label_order) != summ):
|
||||
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 = 1')
|
||||
else:
|
||||
exec ('self.parent.' + label + 'Bool = 0')
|
||||
exec ('self.parent.settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)')
|
||||
self.parent.label_order = '1345'
|
||||
self.parent.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%]'))
|
||||
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)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu0.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpu0)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
|
||||
for core in range(self.parent.numCores):
|
||||
exec ('self.parent.label_coreCpu' + str(core) + ' = Plasma.Label(self.parent.applet)')
|
||||
exec ('self.parent.label_coreCpu' + str(core) + '.setText(text)')
|
||||
exec ('self.parent.layout.addItem(self.parent.label_coreCpu' + str(core) + ')')
|
||||
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat.split('$ccpu')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu1.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpu1)
|
||||
else:
|
||||
self.parent.label_cpu = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
|
||||
line = self.parent.cpuFormat.split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.parent.cpuFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpu.setText(text)
|
||||
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.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]
|
||||
else:
|
||||
line = self.parent.tempFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_temp.setText(text)
|
||||
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%]'))
|
||||
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]
|
||||
elif (self.parent.memFormat.split('$mem')[0] != self.parent.memFormat):
|
||||
self.parent.memInMb = False
|
||||
self.parent.mem_used = 0.0
|
||||
self.parent.mem_free = 1.0
|
||||
self.parent.mem_uf = 0.0
|
||||
line = self.parent.memFormat.split('$mem')[0] + '-----' + self.parent.memFormat.split('$mem')[1]
|
||||
else:
|
||||
line = self.parent.memFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_mem = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_mem.setText(text)
|
||||
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%]'))
|
||||
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]
|
||||
elif (self.parent.swapFormat.split('$swap')[0] != self.parent.swapFormat):
|
||||
self.parent.swapInMb = False
|
||||
self.parent.swap_free = 1.0
|
||||
self.parent.swap_used = 0.0
|
||||
line = self.parent.swapFormat.split('$swap')[0] + '-----' + self.parent.swapFormat.split('$swap')[1]
|
||||
else:
|
||||
line = self.parent.swapFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_swap = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_swap.setText(text)
|
||||
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]'))
|
||||
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.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]
|
||||
else:
|
||||
self.parent.netFormat = self.parent.netNonFormat
|
||||
self.parent.label_netDown = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = self.parent.netFormat.split('$net')[0] + '----'
|
||||
else:
|
||||
line = self.parent.netFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netDown.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_netDown)
|
||||
self.parent.label_netUp = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = '/----' + self.parent.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_netUp.setText(text)
|
||||
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.label_bat = Plasma.Label(self.parent.applet)
|
||||
line = self.parent.batFormat
|
||||
if (line.split('$ac')[0] != line):
|
||||
line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1]
|
||||
if (line.split('$bat')[0] != line):
|
||||
line = line.split('$bat')[0] + '---' + line.split('$bat')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_bat.setText(text)
|
||||
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]'))
|
||||
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)
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock0.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpuclock0)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + "----" + self.parent.formatLine.split('$LINE')[1]
|
||||
for core in range(self.parent.numCores):
|
||||
exec ('self.parent.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.parent.applet)')
|
||||
exec ('self.parent.label_coreCpuclock' + str(core) + '.setText(text)')
|
||||
exec ('self.parent.layout.addItem(self.parent.label_coreCpuclock' + str(core) + ')')
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock1.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpuclock1)
|
||||
else:
|
||||
self.parent.label_cpuclock = Plasma.Label(self.parent.applet)
|
||||
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
|
||||
line = self.parent.cpuclockFormat.split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.parent.cpuclockFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_cpuclock.setText(text)
|
||||
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.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]
|
||||
else:
|
||||
line = self.parent.uptimeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_uptime.setText(text)
|
||||
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.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]
|
||||
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)
|
||||
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.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]
|
||||
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)
|
||||
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: @@/@@%]'))
|
||||
if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
|
||||
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
|
||||
line = self.parent.hddFormat.split('@@')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hdd0 = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_hdd0.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_hdd0)
|
||||
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
|
||||
for mount in self.parent.mountPoints:
|
||||
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + ' = Plasma.Label(self.parent.applet)')
|
||||
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText(text)')
|
||||
exec ('self.parent.layout.addItem(self.parent.label_hdd_' + ''.join(mount.split('/')) + ')')
|
||||
line = self.parent.hddFormat.split('@@')[2]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hdd1 = Plasma.Label(self.parent.applet)
|
||||
self.parent.label_hdd1.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_hdd1)
|
||||
else:
|
||||
line = self.parent.hddFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hdd0.setText(text)
|
||||
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.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]
|
||||
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)
|
||||
self.parent.layout.addItem(self.parent.label_hddtemp)
|
||||
self.parent.applet.setLayout(self.parent.layout)
|
||||
self.parent.theme = Plasma.Svg(self.parent)
|
||||
self.parent.theme.setImagePath("widgets/background")
|
||||
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
self.parent.resize(10,10)
|
||||
|
||||
# create threading
|
||||
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()
|
@ -1,36 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from PyKDE4.kdecore import *
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.notifyrc' % self.applet._name
|
||||
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)
|
Loading…
Reference in New Issue
Block a user