mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
intermediate commit
This commit is contained in:
parent
0fdb7317cc
commit
ce74cdb2d5
@ -1,6 +1,8 @@
|
||||
Ver.1.7.3:
|
||||
+ added readme directory
|
||||
- fix tooltip for custom uptime format
|
||||
- fix #12
|
||||
* more refactoring to the god of refactoring
|
||||
|
||||
Ver.1.7.2:
|
||||
+ added tags $dd, $d, $hh, $h, $mm, $m to custom uptime format
|
||||
|
@ -1,6 +1,8 @@
|
||||
Вер.1.7.3:
|
||||
+ добавлена директория readme
|
||||
- фикс подсказки для кастомного формата аптайма
|
||||
- фикс #12
|
||||
* больше рефакторинга богу рефакторинга
|
||||
|
||||
Вер.1.7.2:
|
||||
+ добавлены тэги $dd, $d, $hh, $h, $mm, $m в кастомный формат аптайма
|
||||
|
@ -26,9 +26,11 @@ class Config():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
self.config = self.applet.config()
|
||||
|
||||
|
||||
|
||||
def get(self, key, default = ''):
|
||||
return self.config.readEntry(key, default).toString()
|
||||
|
||||
|
||||
|
||||
def set(self, key, value):
|
||||
self.config.writeEntry(key, value)
|
||||
|
@ -27,16 +27,17 @@ import config
|
||||
|
||||
|
||||
class ConfigDefinition:
|
||||
def __init__(self, parent, configpage):
|
||||
def __init__(self, parent, configpage, defaults):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
self.configpage = configpage
|
||||
|
||||
|
||||
self.defaults = defaults
|
||||
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
|
||||
# update local variables
|
||||
settings.set('interval', self.configpage.ui.spinBox_interval.value())
|
||||
settings.set('font_family', str(self.configpage.ui.fontComboBox.currentFont().family()))
|
||||
@ -44,7 +45,7 @@ class ConfigDefinition:
|
||||
settings.set('font_color', str(self.configpage.ui.kcolorcombo.color().name()))
|
||||
settings.set('font_style', str(self.configpage.ui.comboBox_style.currentText()))
|
||||
settings.set('font_weight', self.configpage.ui.spinBox_weight.value())
|
||||
|
||||
|
||||
settings.set('custom_time', str(self.configpage.ui.lineEdit_timeFormat.text()))
|
||||
settings.set('custom_uptime', str(self.configpage.ui.lineEdit_uptimeFormat.text()))
|
||||
item = QStringList()
|
||||
@ -68,8 +69,8 @@ class ConfigDefinition:
|
||||
|
||||
settings.set('tooltip_num', self.configpage.ui.spinBox_tooltipNum.value())
|
||||
for label in ['cpu', 'cpuclock', 'mem', 'swap', 'down', 'up']:
|
||||
exec('settings.set("' + label + '_color", str(self.configpage.kcolorcombo_' + label + '.color().name()))')
|
||||
|
||||
settings.set(self.defaults['confColor'][label], str(self.configpage.kcolorcombos[label].color().name()))
|
||||
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'w') as deConfigFile:
|
||||
@ -80,7 +81,7 @@ class ConfigDefinition:
|
||||
deConfigFile.write("CUSTOM=" + str(self.configpage.ui.lineEdit_customCommand.text()) + "\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
self.parent.disconnectFromSource()
|
||||
if (self.parent.uptimeBool > 0):
|
||||
@ -151,9 +152,9 @@ class ConfigDefinition:
|
||||
if (self.parent.customBool > 0):
|
||||
self.parent.label_custom.setText('')
|
||||
self.parent.layout.removeItem(self.parent.label_custom)
|
||||
|
||||
|
||||
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()))
|
||||
if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() > 0):
|
||||
@ -161,18 +162,18 @@ class ConfigDefinition:
|
||||
self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:]
|
||||
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)')
|
||||
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)
|
||||
|
||||
|
||||
# reinitializate
|
||||
self.parent.reInit()
|
||||
|
||||
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
|
||||
font = QFont(str(settings.get('font_family', 'Terminus')), settings.get('font_size', 12).toInt()[0], 400, False)
|
||||
self.configpage.ui.spinBox_interval.setValue(settings.get('interval', 2000).toInt()[0])
|
||||
self.configpage.ui.fontComboBox.setCurrentFont(font)
|
||||
@ -184,7 +185,7 @@ 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")
|
||||
@ -228,7 +229,7 @@ class ConfigDefinition:
|
||||
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.spinBox_tooltipNum.setValue(settings.get('tooltip_num', 100).toInt()[0])
|
||||
self.configpage.ui.kcolorcombo_cpu.setColor(QColor(str(settings.get('cpu_color', '#ff0000'))))
|
||||
self.configpage.ui.kcolorcombo_cpuclock.setColor(QColor(str(settings.get('cpuclock_color', '#00ff00'))))
|
||||
@ -236,8 +237,8 @@ class ConfigDefinition:
|
||||
self.configpage.ui.kcolorcombo_swap.setColor(QColor(str(settings.get('swap_color', '#ffff00'))))
|
||||
self.configpage.ui.kcolorcombo_down.setColor(QColor(str(settings.get('down_color', '#00ffff'))))
|
||||
self.configpage.ui.kcolorcombo_up.setColor(QColor(str(settings.get('up_color', '#ff00ff'))))
|
||||
|
||||
deSettings = {'GPUDEV':'auto', 'HDDDEV':'all', 'MPDADDRESS':'localhost',
|
||||
|
||||
deSettings = {'GPUDEV':'auto', 'HDDDEV':'all', 'MPDADDRESS':'localhost',
|
||||
'MPDPORT':'6600', 'CUSTOM':'wget -qO- http://ifconfig.me/ip'}
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
@ -262,16 +263,17 @@ class ConfigDefinition:
|
||||
self.configpage.ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT']))
|
||||
self.configpage.ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT']))
|
||||
self.configpage.ui.lineEdit_customCommand.setText(deSettings['CUSTOM'])
|
||||
|
||||
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)
|
||||
|
||||
label_order = str(settings.get('label_order', '1345'))
|
||||
for label in self.defaults['order'].keys():
|
||||
bool = self.defaults['confBool'][self.defaults['order'][label]]
|
||||
self.configpage.checkboxes[self.defaults['order'][label]].setCheckState(bool)
|
||||
if (bool > 0):
|
||||
self.configpage.sliders[self.parent.dict_orders[label]].setValue(self.parent.label_order.find(label)+1)
|
||||
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]])))
|
||||
|
||||
self.configpage.sliders[self.defaults['order'][label]].setValue(label_order.find(label)+1)
|
||||
self.configpage.lineedits[self.defaults['order'][label]].setText(str(settings.get(self.defaults['confFormat'][label], self.defaults['format'][label])))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.parent.name()))
|
||||
page.setIcon(KIcon(self.parent.icon()))
|
||||
|
||||
|
||||
parent.okClicked.connect(self.configAccepted)
|
||||
|
@ -30,31 +30,35 @@ class ConfigWindow(QWidget):
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)
|
||||
self.parent = parent
|
||||
self.checkboxes = {'bat':self.ui.checkBox_bat, 'cpu':self.ui.checkBox_cpu,
|
||||
'cpuclock':self.ui.checkBox_cpuclock, 'gpu':self.ui.checkBox_gpu,
|
||||
'gputemp':self.ui.checkBox_gpuTemp, 'hdd':self.ui.checkBox_hdd,
|
||||
'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,
|
||||
'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,
|
||||
'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}
|
||||
|
||||
self.kcolorcombos = {'cpu':self.ui.kcolorcombo_cpu,
|
||||
'cpuclock':self.ui.kcolorcombo_cpuclock, 'down':self.ui.kcolorcombo_down,
|
||||
'mem':self.ui.kcolorcombo_mem, 'swap':self.ui.kcolorcombo_swap,
|
||||
'up':self.ui.kcolorcombo_up}
|
||||
self.checkboxes = {'bat':self.ui.checkBox_bat, 'cpu':self.ui.checkBox_cpu,
|
||||
'cpuclock':self.ui.checkBox_cpuclock, 'custom':self.ui.checkBox_custom,
|
||||
'gpu':self.ui.checkBox_gpu, 'gputemp':self.ui.checkBox_gpuTemp,
|
||||
'hdd':self.ui.checkBox_hdd, '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.lineedits = {'bat':self.ui.lineEdit_bat, 'cpu':self.ui.lineEdit_cpu,
|
||||
'cpuclock':self.ui.lineEdit_cpuclock, 'custom':self.ui.lineEdit_custom,
|
||||
'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}
|
||||
self.sliders = {'bat':self.ui.slider_bat, 'cpu':self.ui.slider_cpu,
|
||||
'cpuclock':self.ui.slider_cpuclock, 'custom':self.ui.slider_custom,
|
||||
'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}
|
||||
|
||||
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)
|
||||
@ -66,8 +70,8 @@ class ConfigWindow(QWidget):
|
||||
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):
|
||||
@ -104,8 +108,8 @@ class ConfigWindow(QWidget):
|
||||
if (self.ui.listWidget_tempDevice.count() > 9):
|
||||
self.ui.listWidget_tempDevice.takeItem(0)
|
||||
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):
|
||||
@ -131,7 +135,7 @@ class ConfigWindow(QWidget):
|
||||
new_value = value + 1
|
||||
second_slider.setValue(new_value)
|
||||
|
||||
|
||||
|
||||
def setStatus(self):
|
||||
"""function to enable label"""
|
||||
for label in self.checkboxes.keys():
|
||||
|
@ -32,8 +32,8 @@ class DataEngine:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
|
||||
|
||||
|
||||
def connectToEngine(self, bools=None, dataEngines=None, interval=1000, names=None):
|
||||
"""function to initializate engine"""
|
||||
if (bools['cpu'] > 0):
|
||||
@ -75,8 +75,8 @@ class DataEngine:
|
||||
dataEngines['time'].connectSource("Local", self.parent, 1000)
|
||||
if (bools['uptime'] > 0):
|
||||
dataEngines['system'].connectSource("system/uptime", self.parent, interval)
|
||||
|
||||
|
||||
|
||||
|
||||
def dataUpdated(self, sourceName, data, ptm):
|
||||
"""function to update data"""
|
||||
adv = ptm['vars']['adv']
|
||||
@ -242,5 +242,5 @@ class DataEngine:
|
||||
updatedData['value'] = value
|
||||
#except:
|
||||
#pass
|
||||
|
||||
|
||||
return updatedData
|
||||
|
@ -43,8 +43,8 @@ class NewPlasmaLabel(Plasma.Label):
|
||||
Plasma.Label.__init__(self, applet)
|
||||
self.parent = parent
|
||||
self.notify = ptmnotify.PTMNotify(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
"""mouse click event"""
|
||||
if (event.button() == Qt.LeftButton):
|
||||
@ -56,50 +56,50 @@ class pyTextWidget(plasmascript.Applet):
|
||||
def __init__(self, parent, args=None):
|
||||
"""widget definition"""
|
||||
plasmascript.Applet.__init__(self, parent)
|
||||
|
||||
|
||||
|
||||
|
||||
def init(self):
|
||||
"""function to initializate widget"""
|
||||
self._name = str(self.package().metadata().pluginName())
|
||||
self.setupVar()
|
||||
|
||||
|
||||
self.dataengine = dataengine.DataEngine(self)
|
||||
self.reinit = reinit.Reinit(self, self.ptm['defaults'])
|
||||
self.tooltipAgent = tooltip.Tooltip(self)
|
||||
|
||||
|
||||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
|
||||
|
||||
|
||||
self.initTooltip()
|
||||
self.reInit()
|
||||
self.applet.setLayout(self.ptm['layout'])
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
|
||||
|
||||
self.setHasConfigurationInterface(True)
|
||||
# Create notifyrc file if required
|
||||
kdehome = unicode(KGlobal.dirs().localkdedir())
|
||||
if ((not os.path.exists(kdehome + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc")) and
|
||||
(not os.path.exists("/usr" + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"))):
|
||||
self.createNotifyrc(kdehome)
|
||||
|
||||
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
self.configpage = configwindow.ConfigWindow(self)
|
||||
self.configdef = configdef.ConfigDefinition(self, self.configpage)
|
||||
self.configdef = configdef.ConfigDefinition(self, self.configpage, self.ptm['defaults'])
|
||||
self.configdef.createConfigurationInterface(parent)
|
||||
|
||||
|
||||
|
||||
|
||||
def createNotifyrc(self, kdehome):
|
||||
"""function to create *.notifyrc"""
|
||||
if (not os.path.isdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")):
|
||||
os.mkdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")
|
||||
shutil.copy(kdehome + "/share/apps/plasma/plasmoids/py-text-monitor/contents/code/plasma_applet_pytextmonitor.notifyrc",
|
||||
kdehome + "/share/apps/plasma_applet_pytextmonitor/")
|
||||
|
||||
|
||||
|
||||
|
||||
def initTooltip(self):
|
||||
"""function to create tooltip"""
|
||||
self.tooltip = Plasma.ToolTipContent()
|
||||
@ -114,24 +114,24 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.tooltip_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
# show tooltip
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
|
||||
|
||||
|
||||
|
||||
|
||||
def updateTooltip(self):
|
||||
"""function to update tooltip"""
|
||||
self.tooltipBound['mem'] = self.memValues['total']
|
||||
self.tooltipBound['swap'] = self.swapValues['total']
|
||||
self.tooltip_view.resize(100.0*(len(self.tooltipReq)-self.tooltipReq.count('up')), 100.0)
|
||||
self.tooltipAgent.createGraphic(self.tooltipReq, self.tooltipColors,
|
||||
self.tooltipAgent.createGraphic(self.tooltipReq, self.tooltipColors,
|
||||
self.tooltipBound, self.tooltipValues, self.tooltip_scene)
|
||||
self.tooltip.setImage(QPixmap.grabWidget(self.tooltip_view))
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
|
||||
|
||||
|
||||
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
"""function to doubleclick event"""
|
||||
os.system("ksysguard &")
|
||||
|
||||
|
||||
|
||||
|
||||
def setupVar(self):
|
||||
"""function to setup variables"""
|
||||
self.ptm = {}
|
||||
@ -139,16 +139,31 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.ptm['dataengine'] = {'ext':None, 'system':None, 'time':None}
|
||||
# defaults
|
||||
self.ptm['defaults'] = {}
|
||||
self.ptm['defaults']['order'] = {'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.ptm['defaults']['format'] = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
|
||||
'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: $down/$upKB/s]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'uptime':'[uptime: $uptime]',
|
||||
self.ptm['defaults']['confBool'] = {'bat':'batBool', 'cpu':'cpuBool',
|
||||
'cpuclock':'cpuclockBool', 'custom':'customBool', 'gpu':'gpuBool',
|
||||
'gputemp':'gputempBool', 'hdd':'hddBool', 'hddtemp':'hddtempBool',
|
||||
'mem':'memBool', 'net':'netBool', 'swap':'swapBool', 'temp':'tempBool',
|
||||
'uptime':'uptimeBool', 'player':'playerBool', 'time':'timeBool'}
|
||||
self.ptm['defaults']['confColor'] = {'cpu':'cpu_color', 'cpuclock':'cpuclock_color',
|
||||
'down':'down_color', 'mem':'mem_color', 'swap':'swap_color', 'up':'up_color'}
|
||||
self.ptm['defaults']['confFormat'] = {'bat':'batFormat', 'cpu':'cpuFormat',
|
||||
'cpuclock':'cpuclockFormat', 'custom':'customFormat', 'gpu':'gpuFormat',
|
||||
'gputemp':'gputempFormat', 'hdd':'hddFormat', 'hddtemp':'hddtempFormat',
|
||||
'mem':'memFormat', 'net':'netFormat', 'swap':'swapFormat', 'temp':'tempFormat',
|
||||
'uptime':'uptimeFormat', 'player':'playerFormat', 'time':'timeFormat'}
|
||||
self.ptm['defaults']['bool'] = {'bat':0, 'cpu':2, 'cpuclock':0, 'custom':0,
|
||||
'gpu':0, 'gputemp':0, 'hdd':0, 'hddtemp':0, 'mem':2, 'net':2, 'swap':2,
|
||||
'temp':0, 'uptime':0, 'player':0, 'time':0}
|
||||
self.ptm['defaults']['format'] = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
|
||||
'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: $down/$upKB/s]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'uptime':'[uptime: $uptime]',
|
||||
'player':'[$artist - $title]', 'time':'[$time]'}
|
||||
self.ptm['defaults']['order'] = {'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'}
|
||||
# labels
|
||||
self.ptm['labels'] = {}
|
||||
self.ptm['layout'] = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
@ -161,9 +176,9 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.ptm['names']['temp'] = []
|
||||
# tooltips
|
||||
self.ptm['tooltip'] = {}
|
||||
self.ptm['tooltip']['bounds'] = {'cpu':100.0, 'cpuclock':4000.0, 'mem':16000.0,
|
||||
self.ptm['tooltip']['bounds'] = {'cpu':100.0, 'cpuclock':4000.0, 'mem':16000.0,
|
||||
'swap':16000, 'down':10000.0, 'up':10000.0}
|
||||
self.ptm['tooltip']['values'] = {'cpu':[0.0, 0.0], 'cpuclock':[0, 0], 'mem':[0, 0],
|
||||
self.ptm['tooltip']['values'] = {'cpu':[0.0, 0.0], 'cpuclock':[0, 0], 'mem':[0, 0],
|
||||
'swap':[0, 0], 'down':[0, 0], 'up':[0, 0]}
|
||||
# values
|
||||
self.ptm['values'] = {}
|
||||
@ -187,7 +202,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.ptm['vars']['bools'] = {}
|
||||
self.ptm['vars']['formats'] = {}
|
||||
self.ptm['vars']['tooltip'] = {}
|
||||
|
||||
|
||||
self.cpuCore = {-1:" 0.0"}
|
||||
self.cpuClockCore = {-1:" 0"}
|
||||
numCores = int(commands.getoutput("grep -c '^processor' /proc/cpuinfo"))
|
||||
@ -204,32 +219,32 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.swapValues = {'free':0.0, 'used':0.0}
|
||||
self.tempNames = []
|
||||
self.temp = {}
|
||||
self.tooltipBound = {'cpu':100.0, 'cpuclock':4000.0, 'mem':16000.0,
|
||||
self.tooltipBound = {'cpu':100.0, 'cpuclock':4000.0, 'mem':16000.0,
|
||||
'swap':16000, 'down':10000.0, 'up':10000.0}
|
||||
self.tooltipColors = {}
|
||||
self.tooltipNum = 100
|
||||
self.tooltipReq = []
|
||||
self.tooltipValues = {'cpu':[0.0, 0.01], 'cpuclock':[0.0, 0.01], 'mem':[0.0, 0.01],
|
||||
self.tooltipValues = {'cpu':[0.0, 0.01], 'cpuclock':[0.0, 0.01], 'mem':[0.0, 0.01],
|
||||
'swap':[0.0, 0.01], 'down':[0.0, 0.01], 'up':[0.0, 0.01]}
|
||||
|
||||
|
||||
# create dictionaries
|
||||
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',
|
||||
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]', 'custom':'[$custom]', 'gpu':'[gpu: $gpu%]',
|
||||
'gputemp':'[gpu temp: $gputemp°C]', 'hdd':'[hdd: $hdd0%]',
|
||||
'hddtemp':'[hdd temp: $hddtemp0°C]', 'mem':'[mem: $mem%]',
|
||||
'net':'[$netdev: $down/$upKB/s]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'uptime':'[uptime: $uptime]',
|
||||
self.dict_defFormat = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
|
||||
'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: $down/$upKB/s]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'uptime':'[uptime: $uptime]',
|
||||
'player':'[$artist - $title]', 'time':'[$time]'}
|
||||
|
||||
|
||||
def showConfigurationInterface(self):
|
||||
"""function to show configuration window"""
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def startPolling(self):
|
||||
try:
|
||||
self.timer.start()
|
||||
@ -259,8 +274,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
if (self.tempBool > 0):
|
||||
self.tempText()
|
||||
self.updateTooltip()
|
||||
|
||||
|
||||
|
||||
|
||||
def batText(self):
|
||||
"""function to set battery text"""
|
||||
line = self.batFormat
|
||||
@ -285,8 +300,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_bat.setText(text)
|
||||
|
||||
|
||||
|
||||
|
||||
def cpuText(self):
|
||||
"""function to set cpu text"""
|
||||
line = self.cpuFormat
|
||||
@ -298,8 +313,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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
|
||||
@ -311,12 +326,12 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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 hddText(self):
|
||||
"""function to set hddtemp text"""
|
||||
|
||||
|
||||
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
try:
|
||||
@ -330,8 +345,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem.setText(text)
|
||||
|
||||
|
||||
|
||||
|
||||
def mountText(self):
|
||||
"""function to set mount text"""
|
||||
line = self.hddFormat
|
||||
@ -340,8 +355,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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
|
||||
@ -353,8 +368,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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"""
|
||||
try:
|
||||
@ -368,8 +383,8 @@ 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 tempText(self):
|
||||
"""function to set temperature text"""
|
||||
line = self.tempFormat
|
||||
@ -378,8 +393,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
# api's functions
|
||||
def addLabel(self, name=None, text=None, add=True):
|
||||
"""function to add new label"""
|
||||
@ -390,8 +405,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
else:
|
||||
self.setText(name, '')
|
||||
self.ptm['layout'].removeItem(self.ptm['labels'][name])
|
||||
|
||||
|
||||
|
||||
|
||||
def applySettings(self, name=None, ptm=None):
|
||||
"""function to read settings"""
|
||||
self.ptm[name] = ptm
|
||||
@ -399,40 +414,39 @@ class pyTextWidget(plasmascript.Applet):
|
||||
for item in ['hdd', 'hddtemp', 'temp']:
|
||||
for value in self.ptm['names'][item]:
|
||||
self.ptm['values'][item][value] = 0.0
|
||||
|
||||
|
||||
|
||||
|
||||
def connectToEngine(self):
|
||||
"""function to connect to dataengines"""
|
||||
self.ptm['dataengine']['ext'] = self.dataEngine("ext-sysmon")
|
||||
self.ptm['dataengine']['system'] = self.dataEngine("systemmonitor")
|
||||
self.ptm['dataengine']['time'] = self.dataEngine("time")
|
||||
self.dataengine.connectToEngine(self.ptm['vars']['bools'], self.ptm['dataengine'],
|
||||
self.dataengine.connectToEngine(self.ptm['vars']['bools'], self.ptm['dataengine'],
|
||||
self.ptm['vars']['app']['interval'], self.ptm['names'])
|
||||
|
||||
|
||||
|
||||
|
||||
def disconnectFromSource(self):
|
||||
"""function to disconnect from sources"""
|
||||
|
||||
|
||||
|
||||
|
||||
def reInit(self):
|
||||
"""function to run reinit"""
|
||||
self.reinit.reinit()
|
||||
if (self.ptm['vars']['adv']['netdevBool'] == 0):
|
||||
self.ptm['names']['net'] = self.setNetdev()
|
||||
self.resize(10, 10)
|
||||
|
||||
|
||||
# create dataengines
|
||||
self.thread().wait(60000)
|
||||
self.connectToEngine()
|
||||
|
||||
|
||||
self.timer.setInterval(self.ptm['vars']['app']['interval'])
|
||||
self.startPolling()
|
||||
|
||||
|
||||
|
||||
|
||||
def setNetdev(self):
|
||||
"""function to set network device"""
|
||||
netdev = "lo"
|
||||
self.ptm['vars']['adv']
|
||||
netdir = self.ptm['vars']['adv']['netDir']
|
||||
interfaces = QDir.entryList(QDir(netdir), QDir.Dirs | QDir.NoDotAndDotDot)
|
||||
for device in interfaces:
|
||||
@ -445,28 +459,88 @@ class pyTextWidget(plasmascript.Applet):
|
||||
pass
|
||||
self.ptm['names']['net'] = netdev
|
||||
return netdev
|
||||
|
||||
|
||||
|
||||
|
||||
def setText(self, name=None, text=None):
|
||||
"""function to set text to labels"""
|
||||
self.ptm['labels'][name].setText(text)
|
||||
|
||||
|
||||
|
||||
|
||||
def textPrepare(self, name=None, text=None):
|
||||
"""function to prepare text"""
|
||||
line = self.ptm['vars']['formats'][name]
|
||||
if (name == "custom"):
|
||||
if (line.split('$custom')[0] != line):
|
||||
line = line.split('$custom')[0] + text + line.split('$custom')[1]
|
||||
elif (name == "gpu"):
|
||||
if (line.split('$gpu')[0] != line):
|
||||
line = line.split('$gpu')[0] + text + line.split('$gpu')[1]
|
||||
elif (name == "gputemp"):
|
||||
if (line.split('$gputemp')[0] != line):
|
||||
line = line.split('$gputemp')[0] + text + line.split('$gputemp')[1]
|
||||
elif (name == "player"):
|
||||
if (line.split('$album')[0] != line):
|
||||
line = line.split('$album')[0] + self.ptm['values']['player']['album'] + line.split('$album')[1]
|
||||
if (line.split('$artist')[0] != line):
|
||||
line = line.split('$artist')[0] + self.ptm['values']['player']['artist'] + line.split('$artist')[1]
|
||||
if (line.split('$progress')[0] != line):
|
||||
line = line.split('$progress')[0] + self.ptm['values']['player']['progress'] + line.split('$progress')[1]
|
||||
if (line.split('$time')[0] != line):
|
||||
line = line.split('$time')[0] + self.ptm['values']['player']['time'] + line.split('$time')[1]
|
||||
if (line.split('$title')[0] != line):
|
||||
line = line.split('$title')[0] + self.ptm['values']['player']['title'] + line.split('$title')[1]
|
||||
elif (name == "time"):
|
||||
if (line.split('$time')[0] != line):
|
||||
line = line.split('$time')[0] + text + line.split('$time')[1]
|
||||
elif (line.split('$isotime')[0] != line):
|
||||
line = line.split('$isotime')[0] + text + line.split('$isotime')[1]
|
||||
elif (line.split('$shorttime')[0] != line):
|
||||
line = line.split('$shorttime')[0] + text + line.split('$shorttime')[1]
|
||||
elif (line.split('$longtime')[0] != line):
|
||||
line = line.split('$longtime')[0] + text + line.split('$longtime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
line = line.split('$custom')[0] + text + line.split('$custom')[1]
|
||||
elif (name == "uptime"):
|
||||
if (line.split('$uptime')[0] != line):
|
||||
line = line.split('$uptime')[0] + text + line.split('$uptime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
line = line.split('$custom')[0] + text + line.split('$custom')[1]
|
||||
output = self.ptm['vars']['app']['format'].split('$LINE')[0] + line + self.ptm['vars']['app']['format'].split('$LINE')[1]
|
||||
return output
|
||||
|
||||
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update label"""
|
||||
updatedData = self.dataengine.dataUpdated(str(sourceName), data, self.ptm)
|
||||
# update tooltips
|
||||
if (updatedData['name'] in ['cpu', 'cpuclock', 'mem', 'swap', 'net']):
|
||||
pass
|
||||
# update labels where is needed
|
||||
if (updatedData['name'] in ['gpu', 'gputemp', 'player']):
|
||||
pass
|
||||
# update falues where is needed
|
||||
if (updatedData['type']):
|
||||
self.ptm['values'][updatedData['name']][updatedData['type']] = updatedData['values']
|
||||
else:
|
||||
if (updatedData['type']):
|
||||
pass
|
||||
self.ptm['values'][updatedData['name']] = updatedData['values']
|
||||
# update labels where is needed
|
||||
if (updatedData['name'] in ['custom', 'gpu', 'gputemp', 'player', 'time', 'uptime']):
|
||||
text = self.textPrepare(updatedData['name'], updatedData['value'])
|
||||
self.setText(updatedData['name'], text)
|
||||
# update tooltips
|
||||
if ((updatedData['name'] in ['cpu', 'cpuclock', 'mem', 'swap', 'net']) and (self.ptm['vars']['bools'][updatedData['name']] == 2)):
|
||||
if (updatedData['name'] == "net"):
|
||||
if (len(self.ptm['tooltip']['values'][updatedData['type']]) > self.ptm['vars']['tooltip']['num']):
|
||||
self.ptm['tooltip']['values'][updatedData['type']] = self.ptm['tooltip']['values'][updatedData['type']][1:]
|
||||
else:
|
||||
pass
|
||||
if (len(self.ptm['tooltip']['values'][updatedData['name']]) > self.ptm['vars']['tooltip']['num']):
|
||||
self.ptm['tooltip']['values'][updatedData['name']] = self.ptm['tooltip']['values'][updatedData['name']][1:]
|
||||
if ((updatedData['name'] in ['cpu', 'cpuclock']) and (updatedData['type'] == -1)):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
elif ((updatedData['name'] == "mem") and (updatedData['type'] == "app")):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
elif ((updatedData['name'] == "mem") and (updatedData['type'] == "used")):
|
||||
self.ptm['tooltip']['bounds']['mem'] = self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used']
|
||||
elif ((updatedData['name'] == "swap") and (updatedData['type'] == "used")):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
self.ptm['tooltip']['bounds']['swap'] = self.ptm['values']['swap']['free'] + self.ptm['values']['swap']['used']
|
||||
elif (updatedData['name'] == "net"):
|
||||
self.ptm['tooltip']['values'][updatedData['type']].append(updatedData['value'])
|
||||
self.update()
|
||||
|
||||
|
||||
|
@ -27,14 +27,14 @@ class PTMNotify:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
|
||||
|
||||
|
||||
def init(self):
|
||||
"""function to init notification"""
|
||||
content = self.initText(self.parent)
|
||||
self.createNotify(content)
|
||||
|
||||
|
||||
|
||||
|
||||
def createNotify(self, content):
|
||||
"""function to create notification for label"""
|
||||
notification = KNotification(content[0])
|
||||
@ -42,8 +42,8 @@ class PTMNotify:
|
||||
notification.setTitle("PyTextMonitor info ::: " + content[0]);
|
||||
notification.setText(content[1]);
|
||||
notification.sendEvent();
|
||||
|
||||
|
||||
|
||||
|
||||
def createText(self, type):
|
||||
"""function to create text"""
|
||||
text = ""
|
||||
@ -174,11 +174,11 @@ class PTMNotify:
|
||||
text = text + "Artist: %s\nAlbum: %s\nTitle: %s" %(artist, album, title)
|
||||
except:
|
||||
text = "Something wrong"
|
||||
|
||||
|
||||
content = [type, text]
|
||||
return content
|
||||
|
||||
|
||||
|
||||
|
||||
def initText(self, sender):
|
||||
"""function to send text"""
|
||||
try:
|
||||
|
@ -29,13 +29,13 @@ class Reinit():
|
||||
self.parent = parent
|
||||
self.defaults = defaults
|
||||
self.labels = defaults['format'].keys()
|
||||
|
||||
|
||||
|
||||
|
||||
def reinit(self):
|
||||
"""function to reinitializate widget"""
|
||||
settings = config.Config(self.parent)
|
||||
ptmVars = {}
|
||||
|
||||
|
||||
ptmVars['adv'] = {}
|
||||
ptmVars['adv']['acDev'] = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
ptmVars['adv']['batDev'] = str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
@ -44,7 +44,7 @@ class Reinit():
|
||||
ptmVars['adv']['netdevBool'] = settings.get('netdevBool', 0).toInt()[0]
|
||||
ptmVars['adv']['netDir'] = str(settings.get('netdir', '/sys/class/net'))
|
||||
ptmVars['adv']['player'] = settings.get('player_name', 0).toInt()[0]
|
||||
|
||||
|
||||
ptmVars['app'] = {}
|
||||
ptmVars['app']['format'] = "<pre><p align=\"center\"><span style=\" font-family:'" + str(settings.get('font_family', 'Terminus')) +\
|
||||
"'; font-style:" + str(settings.get('font_style', 'normal')) + "; font-size:" + str(settings.get('font_size', 12)) +\
|
||||
@ -52,7 +52,7 @@ class Reinit():
|
||||
";\">$LINE</span></p></pre>"
|
||||
ptmVars['app']['interval'] = settings.get('interval', 2000).toInt()[0]
|
||||
ptmVars['app']['order'] = str(settings.get('label_order', '1345'))
|
||||
|
||||
|
||||
ptmVars['tooltip'] = {}
|
||||
ptmVars['tooltip']['colors'] = {}
|
||||
ptmVars['tooltip']['colors']['cpu'] = str(settings.get('cpu_color', '#ff0000'))
|
||||
@ -62,14 +62,11 @@ class Reinit():
|
||||
ptmVars['tooltip']['colors']['down'] = str(settings.get('down_color', '#00ffff'))
|
||||
ptmVars['tooltip']['colors']['up'] = str(settings.get('up_color', '#ff00ff'))
|
||||
ptmVars['tooltip']['num'] = settings.get('tooltip_num', 100).toInt()[0]
|
||||
|
||||
|
||||
ptmVars['bools'] = {}
|
||||
for label in self.labels:
|
||||
if (label in ['cpu', 'mem', 'swap', 'net']):
|
||||
exec("ptmVars['bools'][label] = settings.get('" + label + "Bool', 2).toInt()[0]")
|
||||
else:
|
||||
exec("ptmVars['bools'][label] = settings.get('" + label + "Bool', 0).toInt()[0]")
|
||||
|
||||
ptmVars['bools'][label] = settings.get(self.defaults['confBool'][label], self.defaults['bool'][label]).toInt()[0]
|
||||
|
||||
ptmNames = {}
|
||||
ptmNames['hdd'] = str(settings.get('mount', '/')).split('@@')
|
||||
ptmNames['hddtemp'] = str(settings.get('hdd', '/dev/sda')).split('@@')
|
||||
@ -79,13 +76,13 @@ class Reinit():
|
||||
ptmNames['net'] = ""
|
||||
ptmNames['temp'] = str(settings.get('temp_device', '')).split('@@')
|
||||
self.parent.applySettings('names', ptmNames)
|
||||
|
||||
|
||||
ptmVars['formats'] = {}
|
||||
ptmVars['tooltip']['required'] = []
|
||||
for order in ptmVars['app']['order']:
|
||||
label = self.defaults['order'][order]
|
||||
if (ptmVars['bools'][label] > 0):
|
||||
exec("ptmVars['formats'][label] = str(settings.get('" + label + "Format', self.defaults['format'][label]))")
|
||||
ptmVars['formats'][label] = str(settings.get(self.defaults['confFormat'][label], self.defaults['format'][label]))
|
||||
text = ptmVars['app']['format'].split('$LINE')[0] + ptmVars['formats'][label] + ptmVars['app']['format'].split('$LINE')[1]
|
||||
self.parent.addLabel(label, text, True)
|
||||
if ((label in ['cpu', 'cpuclock', 'mem', 'net', 'swap']) and (ptmVars['bools'][label] == 2)):
|
||||
|
@ -26,15 +26,8 @@ class Tooltip():
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def addValue(self, type, value=0.0, tooltipNum=100):
|
||||
"""function to add value to list"""
|
||||
if (len(self.parent.tooltipValues[type]) > tooltipNum):
|
||||
self.parent.tooltipValues[type] = self.parent.tooltipValues[type][1:]
|
||||
self.parent.tooltipValues[type].append(value)
|
||||
|
||||
|
||||
|
||||
|
||||
def createGraphic(self, types, colors, bounds, values, widget):
|
||||
"""function to create graph"""
|
||||
widget.clear()
|
||||
@ -64,4 +57,4 @@ class Tooltip():
|
||||
widget.addLine(x1, y1, x2, y2, pen)
|
||||
if (type == 'down'):
|
||||
down = True
|
||||
|
||||
|
||||
|
@ -27,32 +27,30 @@ import os
|
||||
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