mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
refactoring of de
This commit is contained in:
@ -81,6 +81,7 @@ class ConfigDefinition:
|
||||
deConfigFile.write("MPDADDRESS=" + str(self.configpage.ui.lineEdit_mpdaddress.text()) + "\n")
|
||||
deConfigFile.write("MPDPORT=" + str(self.configpage.ui.spinBox_mpdport.value()) + "\n")
|
||||
deConfigFile.write("CUSTOM=" + str(self.configpage.ui.lineEdit_customCommand.text()) + "\n")
|
||||
deConfigFile.write("PKGCMD=" + str(self.configpage.ui.comboBox_pkgCommand.currentText()) + "\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -173,7 +174,7 @@ class ConfigDefinition:
|
||||
self.configpage.ui.kcolorcombo_up.setColor(QColor(str(settings.get('up_color', '#ff00ff'))))
|
||||
|
||||
deSettings = {'GPUDEV':'auto', 'HDDDEV':'all', 'MPDADDRESS':'localhost',
|
||||
'MPDPORT':'6600', 'CUSTOM':'wget -qO- http://ifconfig.me/ip'}
|
||||
'MPDPORT':'6600', 'CUSTOM':'wget -qO- http://ifconfig.me/ip', 'PKGCMD':'pacman -Qu'}
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'r') as deConfigFile:
|
||||
@ -197,6 +198,8 @@ 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'])
|
||||
index = self.configpage.ui.comboBox_pkgCommand.findText(deSettings['PKGCMD'])
|
||||
self.configpage.ui.comboBox_pkgCommand.setCurrentIndex(index)
|
||||
|
||||
labelOrder = str(settings.get('label_order', '1345'))
|
||||
for label in self.defaults['order'].keys():
|
||||
|
@ -40,7 +40,8 @@ class ConfigWindow(QWidget):
|
||||
'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,
|
||||
'uptime':self.ui.checkBox_uptime, 'pkg':self.ui.checkBox_pkg,
|
||||
'player':self.ui.checkBox_player, 'ps':self.ui.checkBox_ps,
|
||||
'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,
|
||||
@ -48,7 +49,8 @@ class ConfigWindow(QWidget):
|
||||
'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,
|
||||
'uptime':self.ui.lineEdit_uptime, 'pkg':self.ui.lineEdit_pkg,
|
||||
'player':self.ui.lineEdit_player, 'ps':self.ui.lineEdit_ps,
|
||||
'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,
|
||||
@ -56,7 +58,8 @@ class ConfigWindow(QWidget):
|
||||
'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,
|
||||
'uptime':self.ui.slider_uptime, 'pkg':self.ui.slider_pkg,
|
||||
'player':self.ui.slider_player, 'ps':self.ui.slider_ps,
|
||||
'time':self.ui.slider_time}
|
||||
|
||||
QObject.connect(self.ui.checkBox_netdev, SIGNAL("stateChanged(int)"), self.setNetdevEnabled)
|
||||
|
@ -66,6 +66,9 @@ class DataEngine:
|
||||
dataEngines['system'].connectSource("network/interfaces/" + names['net'] + "/receiver/data", self.parent, interval)
|
||||
if (bools['player'] > 0):
|
||||
dataEngines['ext'].connectSource("player", self.parent, interval)
|
||||
if (bools['ps'] > 0):
|
||||
dataEngines['system'].connectSource("ps", self.parent, interval)
|
||||
dataEngines['system'].connectSource("pscount", self.parent, interval)
|
||||
if (bools['swap'] > 0):
|
||||
dataEngines['system'].connectSource("mem/swap/free", self.parent, interval)
|
||||
dataEngines['system'].connectSource("mem/swap/used", self.parent, interval)
|
||||
@ -191,6 +194,17 @@ class DataEngine:
|
||||
updatedData['value']['progress'] = str(data[QString(u'qmmp_progress')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['time'] = str(data[QString(u'qmmp_duration')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['title'] = str(data[QString(u'qmmp_title')].toUtf8()).decode("utf-8")
|
||||
elif (sourceName == "ps"):
|
||||
print data[QString(u'value')]
|
||||
# updatedData['name'] = "ps"
|
||||
# updatedData['type'] = "num"
|
||||
# value = data[QString(u'value')].toInt()[0]
|
||||
# updatedData['value'] = value
|
||||
elif (sourceName == "pscount"):
|
||||
updatedData['name'] = "ps"
|
||||
updatedData['type'] = "num"
|
||||
value = data[QString(u'value')].toInt()[0]
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
updatedData['name'] = "swap"
|
||||
updatedData['type'] = "free"
|
||||
@ -285,6 +299,9 @@ class DataEngine:
|
||||
dataEngines['system'].disconnectSource("network/interfaces/" + keys['net'] + "/receiver/data", self.parent)
|
||||
elif (name == "player"):
|
||||
dataEngines['ext'].disconnectSource("player", self.parent)
|
||||
elif (name == "ps"):
|
||||
dataEngines['system'].disconnectSource("ps", self.parent)
|
||||
dataEngines['system'].disconnectSource("pscount", self.parent)
|
||||
elif (name == "swap"):
|
||||
dataEngines['system'].disconnectSource("mem/swap/used", self.parent)
|
||||
dataEngines['system'].disconnectSource("mem/swap/free", self.parent)
|
||||
|
@ -132,29 +132,30 @@ class pyTextWidget(plasmascript.Applet):
|
||||
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'}
|
||||
'mem':'memBool', 'net':'netBool', 'pkg':'pkgBool', 'player':'playerBool',
|
||||
'ps':'psBool', 'swap':'swapBool', 'temp':'tempBool', 'uptime':'uptimeBool',
|
||||
'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', 'player':'playerFormat',
|
||||
'swap':'swapFormat', 'temp':'tempFormat', 'time':'timeFormat',
|
||||
'uptime':'uptimeFormat'}
|
||||
'mem':'memFormat', 'net':'netFormat', 'pkg':'pkgFormat',
|
||||
'player':'playerFormat', 'ps':'psFormat', 'swap':'swapFormat',
|
||||
'temp':'tempFormat', 'time':'timeFormat', 'uptime':'uptimeFormat'}
|
||||
self.ptm['defaults']['bool'] = {'bat':0, 'cpu':2, 'cpuclock':0, 'custom':0,
|
||||
'gpu':0, 'gputemp':0, 'hdd':0, 'hddtemp':0, 'mem':2, 'net':2, 'player':0,
|
||||
'swap':2, 'temp':0, 'time':0, 'uptime':0}
|
||||
'gpu':0, 'gputemp':0, 'hdd':0, 'hddtemp':0, 'mem':2, 'net':2, 'pkg':0,
|
||||
'player':0, 'ps':0, 'swap':2, 'temp':0, 'time':0, 'uptime':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]', 'player':'[$artist - $title]',
|
||||
'swap':'[swap: $swap%]', 'temp':'[temp: $temp0°C]',
|
||||
'time':'[$time]', 'uptime':'[uptime: $uptime]'}
|
||||
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'}
|
||||
'net':'[$netdev: $down/$upKB/s]', 'pkg':'[upgrade: $pkgcount]',
|
||||
'player':'[$artist - $title]', 'ps':'[proc: $pscount]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'time':'[$time]', 'uptime':'[uptime: $uptime]'}
|
||||
self.ptm['defaults']['order'] = {'1':'cpu', '2':'temp', '3':'mem', '4':'swap', '5':'net',
|
||||
'6':'bat', '7':'cpuclock', '8':'uptime', '9':'gpu', 'a':'gputemp', 'b':'hdd',
|
||||
'c':'hddtemp', 'd':'player', 'e':'time', 'f':'custom', 'g':'ps', 'h':'pkg'}
|
||||
# labels
|
||||
self.ptm['labels'] = {}
|
||||
self.ptm['layout'] = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
@ -185,6 +186,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.ptm['values']['mem'] = {'app':0.0, 'used':0.0, 'free':1.0}
|
||||
self.ptm['values']['net'] = {"up":0.0, "down":0.0}
|
||||
self.ptm['values']['player'] = {}
|
||||
self.ptm['values']['ps'] = {'list':[], 'num':0}
|
||||
self.ptm['values']['swap'] = {'used':0.0, 'free':1.0}
|
||||
self.ptm['values']['temp'] = {}
|
||||
# variables
|
||||
@ -227,6 +229,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.memText()
|
||||
if (self.ptm['vars']['bools']['net'] > 0):
|
||||
self.netText()
|
||||
if (self.ptm['vars']['bools']['ps'] > 0):
|
||||
self.psText()
|
||||
if (self.ptm['vars']['bools']['swap'] > 0):
|
||||
self.swapText()
|
||||
if (self.ptm['vars']['bools']['temp'] > 0):
|
||||
@ -416,6 +420,16 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.setText("net", text)
|
||||
|
||||
|
||||
def psText(self):
|
||||
"""function to set ps text"""
|
||||
line = self.ptm['vars']['formats']['ps']
|
||||
if (line.split('$pscount')[0] != 0):
|
||||
ps = "%i" % (self.ptm['values']['ps']['num'])
|
||||
line = line.split('$pscount')[0] + ps + line.split('$pscount')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("ps", text)
|
||||
|
||||
|
||||
def swapText(self):
|
||||
"""function to set swap text"""
|
||||
line = self.ptm['vars']['formats']['swap']
|
||||
|
@ -208,6 +208,8 @@ class PTMNotify:
|
||||
return self.createText("network")
|
||||
elif (name == "player"):
|
||||
return self.createText("player")
|
||||
elif (name == "ps"):
|
||||
return self.createText("system")
|
||||
elif (name == "swap"):
|
||||
return self.createText("memory")
|
||||
elif (name == "temp"):
|
||||
|
Reference in New Issue
Block a user