mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
commit before testing
This commit is contained in:
parent
405dda5144
commit
decf714e74
@ -1,20 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
############################################################################
|
||||
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com> #
|
||||
# #
|
||||
# This program is free software; you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU General Public License as published by #
|
||||
# the Free Software Foundation; either version 2 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., #
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #
|
||||
############################################################################
|
||||
|
||||
from util import *
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
@ -53,6 +54,32 @@ class ConfigDefinition:
|
||||
self.parent.font_weight = self.configpage.ui.spinBox_weight.value()
|
||||
settings.set('font_weight', self.parent.font_weight)
|
||||
|
||||
self.parent.custom_time = str(self.configpage.ui.lineEdit_timeFormat.text())
|
||||
settings.set('custom_time', self.parent.custom_time)
|
||||
self.parent.custom_uptime = str(self.configpage.ui.lineEdit_uptimeFormat.text())
|
||||
settings.set('custom_uptime', self.parent.custom_uptime)
|
||||
# temp and mount below
|
||||
self.parent.hddNames = []
|
||||
self.parent.hdd = {}
|
||||
for item in self.configpage.ui.listWidget_hddDevice.items(QMimeData()):
|
||||
self.parent.hddNames.append(str(item.text()))
|
||||
self.parent.hdd[str(item.text())] =" 0.0"
|
||||
settings.set('hdd', '@@'.join(self.parent.hddNames))
|
||||
self.parent.netdir = str(self.configpage.ui.lineEdit_netdir.text())
|
||||
settings.set('netdir', self.parent.netdir)
|
||||
self.parent.netdevBool = str(self.configpage.ui.checkBox_netdev.checkState())
|
||||
settings.set('netdevBool', self.parent.netdevBool)
|
||||
self.parent.custom_netdev = str(self.configpage.ui.comboBox_netdev.currentText())
|
||||
settings.set('custom_netdev', self.parent.custom_netdev)
|
||||
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||
settings.set('battery_device', self.parent.battery_device)
|
||||
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||
settings.set('ac_device', self.parent.ac_device)
|
||||
self.parent.player_name = self.configpage.ui.comboBox_playerSelect.currentIndex()
|
||||
settings.set('player_name', self.parent.player_name)
|
||||
self.parent.custom_command = str(self.configpage.ui.lineEdit_customCommand.text())
|
||||
settings.set('custom_command', self.parent.custom_command)
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
if (self.parent.uptimeBool > 0):
|
||||
self.parent.systemmonitor.disconnectSource("system/uptime", self.parent)
|
||||
@ -60,36 +87,27 @@ class ConfigDefinition:
|
||||
self.parent.layout.removeItem(self.parent.label_uptime)
|
||||
if (self.parent.cpuBool > 0):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/system/TotalLoad", self.parent)
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
self.parent.label_cpu.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpu)
|
||||
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)
|
||||
for core in self.parent.cpuCore.keys():
|
||||
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent)
|
||||
self.parent.label_cpu.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpu)
|
||||
if (self.parent.cpuclockBool > 0):
|
||||
self.parent.systemmonitor.disconnectSource("cpu/system/AverageClock", self.parent)
|
||||
if (self.parent.cpuclockFormat.split('$ccpu')[0] != self.parent.cpuclockFormat):
|
||||
self.parent.label_cpuclock.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpuclock)
|
||||
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)
|
||||
for core in self.parent.cpuClockCore.keys():
|
||||
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self.parent)
|
||||
self.parent.label_cpuclock.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_cpuclock)
|
||||
if (self.parent.tempBool > 0):
|
||||
self.parent.systemmonitor.disconnectSource(self.parent.tempdev, self.parent)
|
||||
for item in self.parent.temp:
|
||||
self.parent.systemmonitor.disconnectSource(item[0], self.parent)
|
||||
self.parent.label_temp.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_temp)
|
||||
self.parent.tempNames = []
|
||||
self.parent.temp = {}
|
||||
for item in self.configpage.ui.listWidget_tempDevice.items(QMimeData()):
|
||||
self.parent.tempNames.append(str(item.text()))
|
||||
self.parent.temp[str(item.text())] =" 0.0"
|
||||
settings.set('temp_device', '@@'.join(self.parent.tempNames))
|
||||
if (self.parent.gpuBool > 0):
|
||||
self.parent.extsysmon.disconnectSource("gpu", self.parent)
|
||||
self.parent.label_gpu.setText('')
|
||||
@ -112,14 +130,16 @@ class ConfigDefinition:
|
||||
self.parent.label_swap.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_swap)
|
||||
if (self.parent.hddBool > 0):
|
||||
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)
|
||||
for item in self.parent.mount:
|
||||
self.parent.systemmonitor.disconnectSource("partitions" + item[0] + "/filllevel", self.parent)
|
||||
self.parent.label_hdd.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_hdd)
|
||||
self.parent.mountNames = []
|
||||
self.parent.mount = {}
|
||||
for item in self.configpage.ui.listWidget_mount.items(QMimeData()):
|
||||
self.parent.mountNames.append(str(item.text()))
|
||||
self.parent.mount[str(item.text())] =" 0.0"
|
||||
settings.set('mount', '@@'.join(self.parent.mountNames))
|
||||
if (self.parent.hddtempBool > 0):
|
||||
self.parent.extsysmon.disconnectSource("hddtemp", self.parent)
|
||||
self.parent.label_hddtemp.setText('')
|
||||
@ -127,10 +147,8 @@ class ConfigDefinition:
|
||||
if (self.parent.netBool > 0):
|
||||
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)
|
||||
self.parent.label_net.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_net)
|
||||
if (self.parent.batBool > 0):
|
||||
self.parent.label_bat.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_bat)
|
||||
@ -142,8 +160,11 @@ class ConfigDefinition:
|
||||
self.parent.timemon.disconnectSource("Local", self.parent)
|
||||
self.parent.label_time.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_time)
|
||||
if (self.parent.customBool > 0):
|
||||
self.parent.label_custom.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_custom)
|
||||
|
||||
self.parent.label_order = "--------------"
|
||||
self.parent.label_order = "---------------"
|
||||
|
||||
for label in self.parent.dict_orders.keys():
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = ' + str(self.configpage.checkboxes[self.parent.dict_orders[label]].checkState()))
|
||||
@ -156,19 +177,7 @@ class ConfigDefinition:
|
||||
else:
|
||||
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||
if (self.parent.dict_orders[label] == 'bat'):
|
||||
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||
settings.set('battery_device', self.parent.battery_device)
|
||||
settings.set('ac_device', self.parent.ac_device)
|
||||
elif (self.parent.dict_orders[label] == 'temp'):
|
||||
self.parent.tempdev = str(self.configpage.ui.comboBox_temp.currentText())
|
||||
settings.set('temp_device', self.parent.tempdev)
|
||||
elif (self.parent.dict_orders[label] == 'player'):
|
||||
self.parent.player_name = self.configpage.ui.comboBox_player.currentIndex()
|
||||
settings.set('player_name', self.parent.player_name)
|
||||
|
||||
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
|
||||
self.parent.label_order = ''.join(self.parent.label_order.split('-'))
|
||||
settings.set('label_order', self.parent.label_order)
|
||||
|
||||
@ -191,6 +200,52 @@ class ConfigDefinition:
|
||||
else:
|
||||
self.configpage.ui.comboBox_style.setCurrentIndex(1)
|
||||
self.configpage.ui.spinBox_weight.setValue(settings.get('font_weight', 400).toInt()[0])
|
||||
|
||||
self.configpage.ui.lineEdit_timeFormat.setText(str(settings.get('custom_time', '$hh:$mm')))
|
||||
self.configpage.ui.lineEdit_uptimeFormat.setText(str(settings.get('custom_uptime', '$ds,$hs,$ms')))
|
||||
commandOut = commands.getoutput("sensors")
|
||||
for item in commandOut.split("\n\n"):
|
||||
for device in item.split("\n"):
|
||||
if (device.find('\xc2\xb0C') > -1):
|
||||
try:
|
||||
tempdev = 'lmsensors/' + item.split("\n")[0] + '/' + '_'.join(device.split(":")[0].split())
|
||||
self.configpage.ui.comboBox_tempDevice.addItem(tempdev)
|
||||
except:
|
||||
pass
|
||||
self.configpage.ui.listWidget_tempDevice.clear()
|
||||
for item in str(settings.get('temp_device', '')).split('@@'):
|
||||
if (len(item) > 0):
|
||||
self.configpage.ui.listWidget_tempDevice.addItem(item)
|
||||
commandOut = commands.getoutput("mount")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
mount = item.split(' on ')[1].split(' type ')[0]
|
||||
self.configpage.ui.comboBox_mount.addItem(mount)
|
||||
except:
|
||||
pass
|
||||
self.configpage.ui.listWidget_mount.clear()
|
||||
for item in str(settings.get('mount', '/')).split('@@'):
|
||||
self.configpage.ui.listWidget_mount.addItem(item)
|
||||
commandOut = commands.getoutput("find /dev -name '[hs]d[a-z]'")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
self.configpage.ui.comboBox_hddDevice.addItem(item)
|
||||
except:
|
||||
pass
|
||||
self.configpage.ui.listWidget_hddDevice.clear()
|
||||
for item in str(settings.get('hdd', '/dev/sda')).split('@@'):
|
||||
self.configpage.ui.listWidget_hddDevice.addItem(item)
|
||||
self.configpage.ui.lineEdit_netdir.setText(str(settings.get('netdir', '/sys/class/net')))
|
||||
self.configpage.ui.checkBox_netdev.setCheckState(settings.get('netdevBool', 0).toInt()[0])
|
||||
for item in QDir.entryList(QDir(str(settings.get('netdir', '/sys/class/net'))), QDir.Dirs | QDir.NoDotAndDotDot):
|
||||
self.configpage.ui.comboBox_netdev.addItem(item)
|
||||
index = self.configpage.ui.comboBox_netdev.findText(str(settings.get('custom_netdev', 'lo')))
|
||||
self.configpage.ui.comboBox_netdev.setCurrentIndex(index)
|
||||
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')))
|
||||
self.configpage.ui.comboBox_playerSelect.setCurrentIndex(settings.get('player_name', 0).toInt()[0])
|
||||
self.configpage.ui.lineEdit_customCommand.setText(str(settings.get('custom_command', 'wget -qO- http://ifconfig.me/ip')))
|
||||
|
||||
for label in self.parent.dict_orders.keys():
|
||||
exec ('bool = self.parent.' + self.parent.dict_orders[label] + 'Bool')
|
||||
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(bool)
|
||||
@ -200,22 +255,6 @@ class ConfigDefinition:
|
||||
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')))
|
||||
elif (self.parent.dict_orders[label] == 'temp'):
|
||||
self.configpage.ui.comboBox_temp.addItem(str(settings.get('temp_device', '<select device>')))
|
||||
commandOut = commands.getoutput("sensors")
|
||||
for adapter in commandOut.split("\n\n"):
|
||||
for device in adapter.split("\n"):
|
||||
if (device.find('\xc2\xb0C') > -1):
|
||||
try:
|
||||
tempdev = 'lmsensors/' + adapter.split('\n')[0] + '/' + '_'.join(device.split(":")[0].split())
|
||||
self.configpage.ui.comboBox_temp.addItem(tempdev)
|
||||
except:
|
||||
pass
|
||||
elif (self.parent.dict_orders[label] == 'player'):
|
||||
self.configpage.ui.comboBox_player.setCurrentIndex(int(settings.get('player_name', 0)))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.parent.name()))
|
||||
|
@ -37,42 +37,99 @@ class ConfigWindow(QWidget):
|
||||
'hddtemp':self.ui.checkBox_hddTemp, 'mem':self.ui.checkBox_mem,
|
||||
'net':self.ui.checkBox_net, 'swap':self.ui.checkBox_swap,
|
||||
'temp':self.ui.checkBox_temp, 'uptime':self.ui.checkBox_uptime,
|
||||
'player':self.ui.checkBox_player, 'time':self.ui.checkBox_time}
|
||||
self.sliders = {'bat':self.ui.slider_bat, 'cpu':self.ui.slider_cpu,
|
||||
'cpuclock':self.ui.slider_cpuclock, 'gpu':self.ui.slider_gpu,
|
||||
'gputemp':self.ui.slider_gpuTemp, 'hdd':self.ui.slider_hdd,
|
||||
'hddtemp':self.ui.slider_hddTemp, 'mem':self.ui.slider_mem,
|
||||
'net':self.ui.slider_net, 'swap':self.ui.slider_swap,
|
||||
'temp':self.ui.slider_temp, 'uptime':self.ui.slider_uptime,
|
||||
'player':self.ui.slider_player, 'time':self.ui.slider_time}
|
||||
'player':self.ui.checkBox_player, 'time':self.ui.checkBox_time,
|
||||
'custom':self.ui.checkBox_custom}
|
||||
self.lineedits = {'bat':self.ui.lineEdit_bat, 'cpu':self.ui.lineEdit_cpu,
|
||||
'cpuclock':self.ui.lineEdit_cpuclock, 'gpu':self.ui.lineEdit_gpu,
|
||||
'gputemp':self.ui.lineEdit_gpuTemp, 'hdd':self.ui.lineEdit_hdd,
|
||||
'hddtemp':self.ui.lineEdit_hddTemp, 'mem':self.ui.lineEdit_mem,
|
||||
'net':self.ui.lineEdit_net, 'swap':self.ui.lineEdit_swap,
|
||||
'temp':self.ui.lineEdit_temp, 'uptime':self.ui.lineEdit_uptime,
|
||||
'player':self.ui.lineEdit_player, 'time':self.ui.lineEdit_time}
|
||||
'player':self.ui.lineEdit_player, 'time':self.ui.lineEdit_time,
|
||||
'custom':self.ui.lineEdit_custom}
|
||||
self.sliders = {'bat':self.ui.slider_bat, 'cpu':self.ui.slider_cpu,
|
||||
'cpuclock':self.ui.slider_cpuclock, 'gpu':self.ui.slider_gpu,
|
||||
'gputemp':self.ui.slider_gpuTemp, 'hdd':self.ui.slider_hdd,
|
||||
'hddtemp':self.ui.slider_hddTemp, 'mem':self.ui.slider_mem,
|
||||
'net':self.ui.slider_net, 'swap':self.ui.slider_swap,
|
||||
'temp':self.ui.slider_temp, 'uptime':self.ui.slider_uptime,
|
||||
'player':self.ui.slider_player, 'time':self.ui.slider_time,
|
||||
'custom':self.ui.slider_custom}
|
||||
|
||||
for item in self.checkboxes.values():
|
||||
QObject.connect(item, SIGNAL("stateChanged(int)"), self.setStatus)
|
||||
QObject.connect(self.ui.checkBox_netdev, SIGNAL("stateChanged(int)"), self.setNetdevEnabled)
|
||||
QObject.connect(self.ui.pushButton_hddDevice, SIGNAL("clicked()"), self.addHddDevice)
|
||||
QObject.connect(self.ui.pushButton_mount, SIGNAL("clicked()"), self.addMount)
|
||||
QObject.connect(self.ui.pushButton_tempDevice, SIGNAL("clicked()"), self.addTempDevice)
|
||||
QObject.connect(self.ui.listWidget_hddDevice, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_hddDevice.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_mount, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_mount.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_tempDevice, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_tempDevice.openPersistentEditor)
|
||||
for item in self.sliders.values():
|
||||
QObject.connect(item, SIGNAL("valueChanged(int)"), self.setSlider)
|
||||
for item in self.checkboxes.values():
|
||||
QObject.connect(item, SIGNAL("stateChanged(int)"), self.setStatus)
|
||||
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""delete events"""
|
||||
if (event.key() == Qt.Key_Delete):
|
||||
if (self.ui.listWidget_hddDevice.hasFocus() and
|
||||
(self.ui.listWidget_hddDevice.currentRow() > -1)):
|
||||
self.ui.listWidget_hddDevice.takeItem(self.ui.listWidget_hddDevice.currentRow())
|
||||
elif (self.ui.listWidget_mount.hasFocus() and
|
||||
(self.ui.listWidget_mount.currentRow() > -1)):
|
||||
self.ui.listWidget_mount.takeItem(self.ui.listWidget_mount.currentRow())
|
||||
elif (self.ui.listWidget_tempDevice.hasFocus() and
|
||||
(self.ui.listWidget_tempDevice.currentRow() > -1)):
|
||||
self.ui.listWidget_tempDevice.takeItem(self.ui.listWidget_tempDevice.currentRow())
|
||||
|
||||
|
||||
def addHddDevice(self):
|
||||
"""function to add mount points"""
|
||||
self.ui.listWidget_hddDevice.addItem(self.ui.comboBox_hddDevice.currentText())
|
||||
|
||||
|
||||
def addMount(self):
|
||||
"""function to add mount points"""
|
||||
self.ui.listWidget_mount.addItem(self.ui.comboBox_mount.currentText())
|
||||
|
||||
|
||||
def addTempDevice(self):
|
||||
"""function to add temperature device"""
|
||||
self.ui.listWidget_tempDevice.addItem(self.ui.comboBox_tempDevice.currentText())
|
||||
|
||||
|
||||
def setNetdevEnabled(self):
|
||||
"""function to set enabled netdev"""
|
||||
if (self.ui.checkBox_netdev.checkState() == 0):
|
||||
self.ui.comboBox_netdev.setDisabled(True)
|
||||
else:
|
||||
self.ui.comboBox_netdev.setEnabled(True)
|
||||
|
||||
|
||||
def setSlider(self):
|
||||
"""function to set sliders"""
|
||||
if (self.sender().isEnabled() == True):
|
||||
second_slider = self.sender()
|
||||
order = []
|
||||
for slider in self.sliders.values():
|
||||
if (slider.isEnabled() == True):
|
||||
order.append(slider.value())
|
||||
if ((slider.value() == self.sender().value()) and (slider != self.sender())):
|
||||
second_slider = slider
|
||||
if (second_slider == self.sender()):
|
||||
return
|
||||
for value in range(len(order)):
|
||||
if (order.count(value+1) == 0):
|
||||
new_value = value + 1
|
||||
second_slider.setValue(new_value)
|
||||
|
||||
|
||||
def setStatus(self):
|
||||
"""function to enable label"""
|
||||
count = self.sliders['bat'].maximum()
|
||||
for label in self.checkboxes.keys():
|
||||
if ((self.checkboxes[label].checkState() > 0) and (self.sliders[label].isEnabled() == False)):
|
||||
self.lineedits[label].setEnabled(True)
|
||||
self.sliders[label].setEnabled(True)
|
||||
if (label == 'bat'):
|
||||
self.ui.lineEdit_acdev.setEnabled(True)
|
||||
self.ui.lineEdit_batdev.setEnabled(True)
|
||||
elif (label == 'temp'):
|
||||
self.ui.comboBox_temp.setEnabled(True)
|
||||
elif (label == 'player'):
|
||||
self.ui.comboBox_player.setEnabled(True)
|
||||
slider_label = 0
|
||||
for slider in self.sliders.values():
|
||||
if (slider.isEnabled() == True):
|
||||
@ -86,13 +143,6 @@ class ConfigWindow(QWidget):
|
||||
elif ((self.checkboxes[label].checkState() == 0) and (self.sliders[label].isEnabled() == True)):
|
||||
self.lineedits[label].setDisabled(True)
|
||||
self.sliders[label].setDisabled(True)
|
||||
if (label == 'bat'):
|
||||
self.ui.lineEdit_acdev.setDisabled(True)
|
||||
self.ui.lineEdit_batdev.setDisabled(True)
|
||||
elif (label == 'temp'):
|
||||
self.ui.comboBox_temp.setDisabled(True)
|
||||
elif (label == 'player'):
|
||||
self.ui.comboBox_player.setDisabled(True)
|
||||
for slider in self.sliders.values():
|
||||
if ((slider.value() == slider.maximum()) and (slider != self.sliders[label])):
|
||||
slider.setValue(self.sliders[label].value())
|
||||
@ -106,23 +156,3 @@ class ConfigWindow(QWidget):
|
||||
else:
|
||||
slider.setMaximum(1)
|
||||
self.sliders[label].setValue(1)
|
||||
|
||||
def setSlider(self):
|
||||
"""function to set sliders"""
|
||||
if (self.sender().isEnabled() == True):
|
||||
second_slider = self.sender()
|
||||
order = []
|
||||
for slider in self.sliders.values():
|
||||
if (slider.isEnabled() == True):
|
||||
order.append(slider.value())
|
||||
if ((slider.value() == self.sender().value()) and (slider != self.sender())):
|
||||
second_slider = slider
|
||||
|
||||
if (second_slider == self.sender()):
|
||||
return
|
||||
|
||||
for value in range(len(order)):
|
||||
if (order.count(value+1) == 0):
|
||||
new_value = value + 1
|
||||
|
||||
second_slider.setValue(new_value)
|
||||
|
@ -29,6 +29,7 @@ timeLetters = ['dddd', 'ddd', 'dd', 'd', \
|
||||
'hh', 'h', 'mm', 'm', 'ss', 's']
|
||||
|
||||
|
||||
|
||||
class DataEngine:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
@ -48,16 +49,17 @@ class DataEngine:
|
||||
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuBool > 0):
|
||||
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):
|
||||
for core in self.parent.cpuCore.keys():
|
||||
if (core > -1):
|
||||
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent, self.parent.interval)
|
||||
if (self.parent.cpuclockBool > 0):
|
||||
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):
|
||||
for core in self.parent.cpuClockCore.keys():
|
||||
if (core > -1):
|
||||
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval)
|
||||
if (self.parent.tempBool > 0):
|
||||
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
|
||||
for item in self.parent.tempNames:
|
||||
self.parent.systemmonitor.connectSource(item, self.parent, self.parent.interval)
|
||||
if (self.parent.gpuBool > 0):
|
||||
self.parent.extsysmon.connectSource("gpu", self.parent, self.parent.interval)
|
||||
if (self.parent.gputempBool > 0):
|
||||
@ -76,8 +78,8 @@ class DataEngine:
|
||||
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, int(self.parent.interval*0.5))
|
||||
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, int(self.parent.interval*0.5))
|
||||
if (self.parent.hddBool > 0):
|
||||
for mount in self.parent.mountPoints:
|
||||
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
|
||||
for item in self.parent.mountNames:
|
||||
self.parent.systemmonitor.connectSource("partitions" + item + "/filllevel", self.parent, self.parent.interval)
|
||||
if (self.parent.hddtempBool > 0):
|
||||
self.parent.extsysmon.connectSource("hddtemp", self.parent, self.parent.interval)
|
||||
if (self.parent.netBool > 0):
|
||||
@ -89,7 +91,8 @@ class DataEngine:
|
||||
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update data"""
|
||||
try:
|
||||
if True:
|
||||
#try:
|
||||
if (sourceName == "system/uptime"):
|
||||
value = datetime.timedelta(0, int(round(float(data[QString(u'value')]), 1)))
|
||||
days = value.days
|
||||
@ -100,89 +103,34 @@ class DataEngine:
|
||||
uptimeText = "%3id%2ih%2im" % (days, hours, minutes)
|
||||
line = line.split('$uptime')[0] + uptimeText + line.split('$uptime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
line = ''.join(line.split('$custom'))
|
||||
if (line.split('$ds')[0] != line):
|
||||
line = "%s%3i%s" % (line.split('$ds')[0], days, line.split('$ds')[1])
|
||||
if (line.split('$hs')[0] != line):
|
||||
line = "%s%2i%s" % (line.split('$hs')[0], hours, line.split('$hs')[1])
|
||||
if (line.split('$ms')[0] != line):
|
||||
line = "%s%2i%s" % (line.split('$ms')[0], minutes, line.split('$ms')[1])
|
||||
uptimeText = self.parent.custom_uptime
|
||||
if (uptimeText.split('$ds')[0] != uptimeText):
|
||||
uptimeText = "%s%3i%s" % (uptimeText.split('$ds')[0], days, uptimeText.split('$ds')[1])
|
||||
if (uptimeText.split('$hs')[0] != uptimeText):
|
||||
uptimeText = "%s%2i%s" % (uptimeText.split('$hs')[0], hours, uptimeText.split('$hs')[1])
|
||||
if (uptimeText.split('$ms')[0] != uptimeText):
|
||||
uptimeText = "%s%2i%s" % (uptimeText.split('$ms')[0], minutes, uptimeText.split('$ms')[1])
|
||||
line = line.split('$custom')[0] + uptimeText + line.split('$custom')[1]
|
||||
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_cpu.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)
|
||||
self.parent.cpuCore[-1] = "%5s" % (value)
|
||||
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)')
|
||||
self.parent.cpuCore[int(str(sourceName)[7])] = "%5s" % (value)
|
||||
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_cpuclock.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)
|
||||
self.parent.cpuClockCore[-1] = "%4s" % (value)
|
||||
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)')
|
||||
self.parent.cpuClockCore[int(str(sourceName)[7])] = "%4s" % (value)
|
||||
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)
|
||||
self.parent.netSpeed["up"] = "%4s" % (value)
|
||||
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)
|
||||
self.parent.netSpeed["down"] = "%4s" % (value)
|
||||
# update network device
|
||||
self.parent.updateNetdev = self.parent.updateNetdev + 1
|
||||
if (self.parent.updateNetdev == 100):
|
||||
@ -197,20 +145,12 @@ class DataEngine:
|
||||
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):
|
||||
elif (str(sourceName).split('/')[0] == "lmsensors"):
|
||||
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)
|
||||
self.parent.temp[sourceName] = "%4s" % (value)
|
||||
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)')
|
||||
self.parent.mount['/'+'/'.join(str(sourceName).split('/')[1:-1])] = "%5s" % (value)
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.parent.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
@ -260,15 +200,13 @@ class DataEngine:
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_gputemp.setText(text)
|
||||
elif (sourceName == "hddtemp"):
|
||||
hddtempText = []
|
||||
for device in self.parent.hddtempFormat.split('@@')[1].split(';'):
|
||||
if (len(device) > 0):
|
||||
value = str(data[QString(device)])
|
||||
hddtempText.append("%4s" % (value))
|
||||
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
|
||||
line = self.parent.hddtempFormat.split('@@')[0] + ' '.join(hddtempText) + self.parent.hddtempFormat.split('@@')[2]
|
||||
else:
|
||||
line = self.parent.hddtempFormat
|
||||
for item in self.parent.hddNames:
|
||||
value = str(data[QString(item)])
|
||||
self.parent.hdd[item] = "%4s" % (value)
|
||||
line = self.parent.hddtempFormat
|
||||
for i in range(len(self.parent.hddNames)):
|
||||
if (line.split('$hddtemp'+str(i))[0] != line):
|
||||
line = line.split('$hddtemp'+str(i))[0] + self.parent.hdd[self.parent.hddNames[i]] + line.split('$hddtemp'+str(i))[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hddtemp.setText(text)
|
||||
elif (sourceName == "player"):
|
||||
@ -318,29 +256,20 @@ class DataEngine:
|
||||
elif (self.parent.timeFormat.split('$longtime')[0] != self.parent.timeFormat):
|
||||
value = str(data[QString(u'DateTime')].toString(Qt.SystemLocaleLongDate).toUtf8())
|
||||
line = self.parent.timeFormat.split('$longtime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$longtime')[1]
|
||||
elif (self.parent.timeFormat.split('$snsntime')[0] != self.parent.timeFormat):
|
||||
rawDate = str(data[QString(u'DateTime')].toString(Qt.TextDate).toUtf8())
|
||||
value = rawDate.split()[0] + " " + rawDate.split()[2] + " " + \
|
||||
rawDate.split()[1] + " " + ':'.join(rawDate.split()[3].split(':')[0:2])
|
||||
line = self.parent.timeFormat.split('$snsntime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$snsntime')[1]
|
||||
elif (self.parent.timeFormat.split('$nsnstime')[0] != self.parent.timeFormat):
|
||||
rawDate = str(data[QString(u'DateTime')].toString(Qt.TextDate).toUtf8())
|
||||
value = ':'.join(rawDate.split()[3].split(':')[0:2]) + " " + rawDate.split()[0] + " " + \
|
||||
rawDate.split()[2] + " " + rawDate.split()[1]
|
||||
line = self.parent.timeFormat.split('$nsnstime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$nsnstime')[1]
|
||||
elif (self.parent.timeFormat.split('$custom')[0] != self.parent.timeFormat):
|
||||
rawDate = data[QString(u'DateTime')]
|
||||
line = ''.join(self.parent.timeFormat.split('$custom'))
|
||||
value = self.parent.custom_time
|
||||
for letters in timeLetters:
|
||||
if (line.split('$'+letters)[0] != line):
|
||||
line = line.split('$'+letters)[0] + \
|
||||
if (value.split('$'+letters)[0] != value):
|
||||
value = value.split('$'+letters)[0] + \
|
||||
str(data[QString(u'DateTime')].toString(letters).toUtf8()).decode("utf-8") + \
|
||||
line.split('$'+letters)[1]
|
||||
value.split('$'+letters)[1]
|
||||
line = self.parent.timeFormat.split('$custom')[0] + value + self.parent.timeFormat.split('$custom')[1]
|
||||
else:
|
||||
line = self.parent.timeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_time.setText(text)
|
||||
|
||||
self.parent.update()
|
||||
except:
|
||||
pass
|
||||
#except:
|
||||
#pass
|
||||
|
@ -96,41 +96,48 @@ class pyTextWidget(plasmascript.Applet):
|
||||
def setupNetdev(self):
|
||||
"""function to setup network device"""
|
||||
netdev = "lo"
|
||||
try:
|
||||
interfaces = []
|
||||
for line in commands.getoutput("ifconfig -a -s").split("\n"):
|
||||
if ((line.split()[0] != 'Iface') and (line.split()[0] != 'lo')):
|
||||
interfaces.append(line.split()[0])
|
||||
|
||||
for device in interfaces:
|
||||
if (commands.getoutput("ifconfig " + device + " | grep 'inet '") != ''):
|
||||
netdev = device
|
||||
break
|
||||
except:
|
||||
pass
|
||||
interfaces = QDir.entryList(QDir(self.netdir), QDir.Dirs | QDir.NoDotAndDotDot)
|
||||
for device in interfaces:
|
||||
if (str(device) != "lo"):
|
||||
try:
|
||||
with open(self.netdir+"/"+str(device)+"/operstate", "r") as stateFile:
|
||||
if (stateFile.readline() == "up\n"):
|
||||
netdev = str(device)
|
||||
except:
|
||||
pass
|
||||
return netdev
|
||||
|
||||
|
||||
def setupVar(self):
|
||||
"""function to setup variables"""
|
||||
self.netdev = ''
|
||||
# setup number of cores
|
||||
commandOut = commands.getoutput("grep -c '^processor' /proc/cpuinfo")
|
||||
self.numCores = int(commandOut)
|
||||
self.tempdev = "tempdevice"
|
||||
self.cpuCore = {-1:" 0.0"}
|
||||
self.cpuClockCore = {-1:" 0"}
|
||||
numCores = int(commands.getoutput("grep -c '^processor' /proc/cpuinfo"))
|
||||
for i in range(numCores):
|
||||
self.cpuCore[i] = str(" 0.0")
|
||||
self.cpuClockCore[i] = str(" 0")
|
||||
self.netSpeed = {"up":" 0", "down":" 0"}
|
||||
self.tempNames = []
|
||||
self.temp = {}
|
||||
self.mountNames = []
|
||||
self.mount = {}
|
||||
self.hddNames = []
|
||||
self.hdd = {}
|
||||
|
||||
# create dictionaries
|
||||
self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', '9':'gpu', 'a':'gputemp',
|
||||
'b':'hdd', 'c':'hddtemp', '3':'mem', '5':'net', '4':'swap', '2':'temp', '8':'uptime',
|
||||
'd':'player', 'e':'time'}
|
||||
self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', 'f':'custom', '9':'gpu',
|
||||
'a':'gputemp', 'b':'hdd', 'c':'hddtemp', '3':'mem', '5':'net', '4':'swap', '2':'temp',
|
||||
'8':'uptime', 'd':'player', 'e':'time'}
|
||||
self.dict_defFormat = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
|
||||
'cpuclock':'[mhz: $cpucl]', 'gpu':'[gpu: $gpu%]',
|
||||
'gputemp':'[gpu temp: $gputemp°C]', 'hdd':'[hdd: @@/@@%]',
|
||||
'hddtemp':'[hdd temp: @@/dev/sda@@°C]', 'mem':'[mem: $mem%]',
|
||||
'cpuclock':'[mhz: $cpucl]', 'custom':'[$custom]', 'gpu':'[gpu: $gpu%]',
|
||||
'gputemp':'[gpu temp: $gputemp°C]', 'hdd':'[hdd: $hdd0%]',
|
||||
'hddtemp':'[hdd temp: $hddtemp0°C]', 'mem':'[mem: $mem%]',
|
||||
'net':'[$netdev: $netKB/s]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp°C]', 'uptime':'[uptime: $uptime]',
|
||||
'player':'[$artist - $title]', 'time':'[$time]'}
|
||||
|
||||
|
||||
|
||||
def showConfigurationInterface(self):
|
||||
"""function to show configuration window"""
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
@ -147,15 +154,26 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_error.setText('<font color="red">ERROR</font>')
|
||||
self.layout.addItem(self.label_error)
|
||||
return
|
||||
|
||||
|
||||
|
||||
def updateLabel(self):
|
||||
"""function to update label"""
|
||||
if ((self.memBool > 0) and (self.memInMb == False)):
|
||||
self.memText()
|
||||
if ((self.swapBool > 0) and (self.swapInMb == False)):
|
||||
self.swapText()
|
||||
if (self.batBool > 0):
|
||||
self.batText()
|
||||
if (self.cpuBool > 0):
|
||||
self.cpuText()
|
||||
if (self.cpuclockBool > 0):
|
||||
self.cpuclockText()
|
||||
if (self.hddBool > 0):
|
||||
self.mountText()
|
||||
if ((self.memBool > 0) and (self.memInMb == False)):
|
||||
self.memText()
|
||||
if (self.netBool > 0):
|
||||
self.netText()
|
||||
if ((self.swapBool > 0) and (self.swapInMb == False)):
|
||||
self.swapText()
|
||||
if (self.tempBool > 0):
|
||||
self.tempText()
|
||||
|
||||
|
||||
def batText(self):
|
||||
@ -169,7 +187,6 @@ class pyTextWidget(plasmascript.Applet):
|
||||
bat = 'off'
|
||||
bat = "%3s" % (bat)
|
||||
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
|
||||
|
||||
if (line.split('$ac')[0] != line):
|
||||
try:
|
||||
with open (self.ac_device, 'r') as bat_file:
|
||||
@ -185,6 +202,32 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_bat.setText(text)
|
||||
|
||||
|
||||
def cpuText(self):
|
||||
"""function to set cpu text"""
|
||||
line = self.cpuFormat
|
||||
for core in self.cpuCore.keys():
|
||||
if (core > -1):
|
||||
if (line.split('$cpu'+str(core))[0] != line):
|
||||
line = line.split('$cpu'+str(core))[0] + self.cpuCore[core] + line.split('$cpu'+str(core))[1]
|
||||
if (line.split('$cpu')[0] != line):
|
||||
line = line.split('$cpu')[0] + self.cpuCore[-1] + line.split('$cpu')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu.setText(text)
|
||||
|
||||
|
||||
def cpuclockText(self):
|
||||
"""function to set cpu clock text"""
|
||||
line = self.cpuclockFormat
|
||||
for core in self.cpuclockCore.keys():
|
||||
if (core > -1):
|
||||
if (line.split('$cpucl'+str(core))[0] != line):
|
||||
line = line.split('$cpucl'+str(core))[0] + self.cpuclockCore[core] + line.split('$cpucl'+str(core))[1]
|
||||
if (line.split('$cpucl')[0] != line):
|
||||
line = line.split('$cpucl')[0] + self.cpuclockCore[-1] + line.split('$cpucl')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock.setText(text)
|
||||
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
full = self.mem_uf + self.mem_free
|
||||
@ -201,6 +244,27 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_mem.setText(text)
|
||||
|
||||
|
||||
def mountText(self):
|
||||
"""function to set mount text"""
|
||||
line = self.hddFormat
|
||||
for i in self.mountNames:
|
||||
if (line.split('$hdd'+str(i))[0] != line):
|
||||
line = line.split('$hdd'+str(i))[0] + self.mount[self.mountNames[i]] + line.split('$hdd'+str(i))[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_hdd.setText(text)
|
||||
|
||||
|
||||
def netText(self):
|
||||
"""function to set network text"""
|
||||
line = self.netFormat
|
||||
if (line.split('$up')[0] != line):
|
||||
line = line.split('$up')[0] + self.netSpeed['up'] + line.split('$up')[1]
|
||||
if (line.split('$down')[0] != line):
|
||||
line = line.split('$down')[0] + self.netSpeed['down'] + line.split('$down')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_net.setText(text)
|
||||
|
||||
|
||||
def swapText(self):
|
||||
"""function to set swap text"""
|
||||
full = self.swap_used + self.swap_free
|
||||
@ -217,6 +281,16 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_swap.setText(text)
|
||||
|
||||
|
||||
def tempText(self):
|
||||
"""function to set temperature text"""
|
||||
line = self.tempFormat
|
||||
for i in self.tempNames:
|
||||
if (line.split('$temp'+str(i))[0] != line):
|
||||
line = line.split('$temp'+str(i))[0] + self.temp[self.tempNames[i]] + line.split('$temp'+str(i))[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_temp.setText(text)
|
||||
|
||||
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update label"""
|
||||
|
@ -236,7 +236,7 @@ class PTMNotify:
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if (sender == self.parent.parent.label_hdd0):
|
||||
if (sender == self.parent.parent.label_hdd):
|
||||
content = self.createText("disk")
|
||||
return content
|
||||
except:
|
||||
@ -248,7 +248,7 @@ class PTMNotify:
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if (sender == self.parent.parent.label_netDown):
|
||||
if (sender == self.parent.parent.label_net):
|
||||
content = self.createText("network")
|
||||
return content
|
||||
except:
|
||||
@ -265,3 +265,9 @@ class PTMNotify:
|
||||
return content
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if (sender == self.parent.parent.label_custom):
|
||||
content = self.createText("system")
|
||||
return content
|
||||
except:
|
||||
pass
|
||||
|
@ -59,180 +59,123 @@ class Reinit():
|
||||
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.custom_time = str(settings.get('custom_time', '$hh:$mm'))
|
||||
self.parent.custom_uptime = str(settings.get('custom_uptime', '$ds,$hs,$ms'))
|
||||
self.parent.tempNames = []
|
||||
self.parent.temp = {}
|
||||
for item in str(settings.get('temp_device', '')).split('@@'):
|
||||
self.parent.tempNames.append(item)
|
||||
self.parent.temp[item] =" 0.0"
|
||||
self.parent.mountNames = []
|
||||
self.parent.mount = {}
|
||||
for item in str(settings.get('mount', '/')).split('@@'):
|
||||
self.parent.mountNames.append(item)
|
||||
self.parent.mount[item] =" 0.0"
|
||||
self.parent.hddNames = []
|
||||
self.parent.hdd = {}
|
||||
for item in str(settings.get('hdd', '/dev/sda')).split('@@'):
|
||||
self.parent.hddNames.append(item)
|
||||
self.parent.hdd[item] =" 0.0"
|
||||
self.parent.netdir = str(settings.get('netdir', '/sys/class/net'))
|
||||
self.parent.netdevBool = settings.get('netdevBool', 0).toInt()[0]
|
||||
self.parent.custom_netdev = str(settings.get('custom_netdev', 'lo'))
|
||||
self.parent.battery_device = str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.parent.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.parent.player_name = settings.get('player_name', 0).toInt()[0]
|
||||
self.parent.custom_command = str(settings.get('custom_command', 'wget -qO- http://ifconfig.me/ip'))
|
||||
|
||||
self.parent.label_order = str(settings.get('label_order', '1345'))
|
||||
for label in self.parent.dict_orders.values():
|
||||
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
|
||||
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 2))')
|
||||
exec ('self.parent.' + label + 'Bool = settings.get("' + label + 'Bool", 2).toInt()[0]')
|
||||
else:
|
||||
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))')
|
||||
exec ('self.parent.' + label + 'Bool = settings.get("' + label + 'Bool", 0).toInt()[0]')
|
||||
|
||||
# labels
|
||||
for order in self.parent.label_order:
|
||||
if (order == "1"):
|
||||
if (self.parent.cpuBool > 0):
|
||||
self.parent.cpuFormat = str(settings.get('cpuFormat', '[cpu: $cpu%]'))
|
||||
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
|
||||
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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_cpu.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpu)
|
||||
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 = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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)
|
||||
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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 > 0):
|
||||
self.parent.tempdev = str(settings.get('temp_device', '<select device>'))
|
||||
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp°C]'))
|
||||
self.parent.label_temp = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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
|
||||
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 > 0):
|
||||
self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]'))
|
||||
self.parent.label_mem = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
|
||||
self.parent.memInMb = True
|
||||
line = self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[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
|
||||
line = self.parent.memFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_mem = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
self.parent.label_mem.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_mem)
|
||||
elif (order == "4"):
|
||||
if (self.parent.swapBool > 0):
|
||||
self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]'))
|
||||
self.parent.label_swap = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
|
||||
self.parent.swapInMb = True
|
||||
line = self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[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
|
||||
line = self.parent.swapFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_swap = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
self.parent.label_swap.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_swap)
|
||||
elif (order == "5"):
|
||||
if (self.parent.netBool > 0):
|
||||
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]'))
|
||||
if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat):
|
||||
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
|
||||
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
|
||||
self.parent.label_net = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
if (self.parent.netdevBool > 0):
|
||||
self.parent.netdev = self.parent.custom_netdev
|
||||
else:
|
||||
self.parent.netdev = 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 = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
|
||||
line = self.parent.netFormat.split('$net')[0] + '----'
|
||||
else:
|
||||
line = self.parent.netFormat
|
||||
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)
|
||||
self.parent.label_net.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_net)
|
||||
elif (order == "6"):
|
||||
if (self.parent.batBool > 0):
|
||||
self.parent.batFormat = str(settings.get('batFormat', '[bat: $bat%$ac]'))
|
||||
self.parent.battery_device= str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.parent.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.parent.label_bat = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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 > 0):
|
||||
self.parent.cpuclockFormat = str(settings.get('cpuclockFormat', '[mhz: $cpucl]'))
|
||||
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
|
||||
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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_cpuclock.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_cpuclock)
|
||||
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 = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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)
|
||||
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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 > 0):
|
||||
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
|
||||
self.parent.label_uptime = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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
|
||||
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)
|
||||
@ -240,10 +183,7 @@ class Reinit():
|
||||
if (self.parent.gpuBool > 0):
|
||||
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
|
||||
self.parent.label_gpu = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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
|
||||
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)
|
||||
@ -251,65 +191,31 @@ class Reinit():
|
||||
if (self.parent.gputempBool > 0):
|
||||
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
||||
self.parent.label_gputemp = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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
|
||||
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 > 0):
|
||||
self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: @@/@@%]'))
|
||||
if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
|
||||
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
|
||||
line = self.parent.hddFormat.split('@@')[0]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hdd0 = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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)
|
||||
self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: $hdd0%]'))
|
||||
self.parent.label_hdd = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
line = self.parent.hddFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_hdd.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_hdd)
|
||||
elif (order == "c"):
|
||||
if (self.parent.hddtempBool > 0):
|
||||
self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@°C]'))
|
||||
self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: $hddtemp0°C]'))
|
||||
self.parent.label_hddtemp = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
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
|
||||
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)
|
||||
elif (order == "d"):
|
||||
if (self.parent.playerBool > 0):
|
||||
self.parent.playerFormat = str(settings.get('playerFormat', '[$artist - $title]'))
|
||||
self.parent.player_name = settings.get('player_name', 0).toInt()[0]
|
||||
self.parent.label_player = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
line = self.parent.playerFormat
|
||||
if (line.split('$album')[0] != line):
|
||||
line = line.split('$album')[0] + 'N\\A' + line.split('$album')[1]
|
||||
if (line.split('$artist')[0] != line):
|
||||
line = line.split('$artist')[0] + 'N\\A' + line.split('$artist')[1]
|
||||
if (line.split('$progress')[0] != line):
|
||||
line = line.split('$progress')[0] + '00:00' + line.split('$progress')[1]
|
||||
if (line.split('$title')[0] != line):
|
||||
line = line.split('$title')[0] + 'N\\A' + line.split('$title')[1]
|
||||
if (line.split('$time')[0] != line):
|
||||
line = line.split('$time')[0] + '00:00' + line.split('$time')[1]
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_player.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_player)
|
||||
@ -317,13 +223,18 @@ class Reinit():
|
||||
if (self.parent.timeBool > 0):
|
||||
self.parent.timeFormat = str(settings.get('timeFormat', '[$time]'))
|
||||
self.parent.label_time = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
if (self.parent.timeFormat.split('$time')[0] != self.parent.timeFormat):
|
||||
line = self.parent.timeFormat.split('$time')[0] + '----------------------' + self.parent.timeFormat.split('$time')[1]
|
||||
else:
|
||||
line = self.parent.timeFormat
|
||||
line = self.parent.timeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_time.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_time)
|
||||
elif (order == "f"):
|
||||
if (self.parent.customBool > 0):
|
||||
self.parent.customFormat = str(settings.get('customFormat', '[$custom]'))
|
||||
self.parent.label_custom = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||
line = self.parent.customFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_custom.setText(text)
|
||||
self.parent.layout.addItem(self.parent.label_custom)
|
||||
if not confAccept:
|
||||
self.parent.layout.setContentsMargins(1, 1, 1, 1)
|
||||
self.parent.applet.setLayout(self.parent.layout)
|
||||
|
@ -1,20 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
############################################################################
|
||||
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com> #
|
||||
# #
|
||||
# This program is free software; you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU General Public License as published by #
|
||||
# the Free Software Foundation; either version 2 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., #
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #
|
||||
############################################################################
|
||||
|
||||
from shutil import copyfile
|
||||
from PyKDE4.kdecore import *
|
||||
|
@ -313,7 +313,7 @@ $cpucl7 - CPU clock for core 7, MHz</string>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_temp">
|
||||
<property name="toolTip">
|
||||
<string>$temp - physical temperature on CPU</string>
|
||||
<string>$tempN - physical temperature on device N (from 0). Example: $temp0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -605,7 +605,7 @@ $swapmb - swap usage, MB</string>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_hdd">
|
||||
<property name="toolTip">
|
||||
<string>$hddN - usage for mount point N, %. Example: $hdd0</string>
|
||||
<string>$hddN - usage for mount point N (from 0), %. Example: $hdd0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -663,7 +663,7 @@ $swapmb - swap usage, MB</string>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_hddTemp">
|
||||
<property name="toolTip">
|
||||
<string>$hddtempN - physical temperature on device N. Example: $hddtemp0</string>
|
||||
<string>$hddtempN - physical temperature on device N (from 0). Example: $hddtemp0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -721,7 +721,8 @@ $swapmb - swap usage, MB</string>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_net">
|
||||
<property name="toolTip">
|
||||
<string>$net - network speed, down/up, KB/s
|
||||
<string>$down - download speed, KB/s
|
||||
$up - upload speed, KB/s
|
||||
$netdev - current network device</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
@ -1223,6 +1224,9 @@ del - remove item</string>
|
||||
<property name="toolTip">
|
||||
<string>"/sys/class/net" by default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -1247,6 +1251,9 @@ del - remove item</string>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_netdev">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
Loading…
Reference in New Issue
Block a user