mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
Prerelease 1.7.2
This commit is contained in:
@ -21,7 +21,7 @@ from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
import commands
|
||||
import commands, os
|
||||
import config
|
||||
|
||||
|
||||
@ -78,8 +78,6 @@ class ConfigDefinition:
|
||||
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)
|
||||
|
||||
self.parent.tooltipNum = self.configpage.ui.spinBox_tooltipNum.value()
|
||||
settings.set('tooltip_num', self.parent.tooltipNum)
|
||||
@ -87,6 +85,17 @@ class ConfigDefinition:
|
||||
exec ('self.parent.tooltipColors["' + label + '"] = str(self.configpage.kcolorcombo_' + label + '.color().name())')
|
||||
exec ('settings.set("' + label + '_color", self.parent.tooltipColors["' + label + '"])')
|
||||
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'w') as deConfigFile:
|
||||
deConfigFile.write("GPUDEV=" + str(self.configpage.ui.comboBox_gpudev.currentText()) + "\n")
|
||||
deConfigFile.write("HDDDEV=" + str(self.configpage.ui.comboBox_hdddev.currentText()) + "\n")
|
||||
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")
|
||||
except:
|
||||
pass
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
if (self.parent.uptimeBool > 0):
|
||||
self.parent.systemmonitor.disconnectSource("system/uptime", self.parent)
|
||||
@ -253,7 +262,6 @@ 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.lineEdit_customCommand.setText(str(settings.get('custom_command', 'wget -qO- http://ifconfig.me/ip')))
|
||||
|
||||
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'))))
|
||||
@ -263,6 +271,32 @@ class ConfigDefinition:
|
||||
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',
|
||||
'MPDPORT':'6600', 'CUSTOM':'wget -qO- http://ifconfig.me/ip'}
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'r') as deConfigFile:
|
||||
for line in deConfigFile:
|
||||
if ((line[0] != '#') and (line.split('=')[0] != line)):
|
||||
deSettings[line.split('=')[0]] = line.split('=')[1][:-1]
|
||||
except:
|
||||
pass
|
||||
index = self.configpage.ui.comboBox_gpudev.findText(deSettings['GPUDEV'])
|
||||
self.configpage.ui.comboBox_gpudev.setCurrentIndex(index)
|
||||
self.configpage.ui.comboBox_hdddev.addItem("all")
|
||||
commandOut = commands.getoutput("find /dev -name '[hs]d[a-z]'")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
self.configpage.ui.comboBox_hdddev.addItem(item)
|
||||
except:
|
||||
pass
|
||||
index = self.configpage.ui.comboBox_hdddev.findText(deSettings['HDDDEV'])
|
||||
self.configpage.ui.comboBox_hdddev.setCurrentIndex(index)
|
||||
self.configpage.ui.lineEdit_mpdaddress.setText(deSettings['MPDADDRESS'])
|
||||
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)
|
||||
|
@ -88,6 +88,8 @@ class DataEngine:
|
||||
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
|
||||
if (self.parent.playerBool > 0):
|
||||
self.parent.extsysmon.connectSource("player", self.parent, self.parent.interval)
|
||||
if (self.parent.customBool > 0):
|
||||
self.parent.extsysmon.connectSource("custom", self.parent, self.parent.interval)
|
||||
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update data"""
|
||||
@ -103,12 +105,18 @@ class DataEngine:
|
||||
line = line.split('$uptime')[0] + uptimeText + line.split('$uptime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
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])
|
||||
if (uptimeText.split('$dd')[0] != uptimeText):
|
||||
uptimeText = "%s%03i%s" % (uptimeText.split('$dd')[0], days, uptimeText.split('$dd')[1])
|
||||
if (uptimeText.split('$d')[0] != uptimeText):
|
||||
uptimeText = "%s%3i%s" % (uptimeText.split('$d')[0], days, uptimeText.split('$d')[1])
|
||||
if (uptimeText.split('$hh')[0] != uptimeText):
|
||||
uptimeText = "%s%02i%s" % (uptimeText.split('$hh')[0], hours, uptimeText.split('$hh')[1])
|
||||
if (uptimeText.split('$h')[0] != uptimeText):
|
||||
uptimeText = "%s%2i%s" % (uptimeText.split('$h')[0], hours, uptimeText.split('$h')[1])
|
||||
if (uptimeText.split('$mm')[0] != uptimeText):
|
||||
uptimeText = "%s%02i%s" % (uptimeText.split('$mm')[0], minutes, uptimeText.split('$mm')[1])
|
||||
if (uptimeText.split('$m')[0] != uptimeText):
|
||||
uptimeText = "%s%2i%s" % (uptimeText.split('$m')[0], minutes, uptimeText.split('$m')[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)
|
||||
@ -280,6 +288,14 @@ class DataEngine:
|
||||
line = self.parent.timeFormat
|
||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||
self.parent.label_time.setText(text)
|
||||
elif (sourceName == "custom"):
|
||||
value = str(data[QString(u'custom')].toUtf8()).decode("utf-8")
|
||||
if (self.parent.customFormat.split('$custom')[0] != self.parent.customFormat):
|
||||
line = self.parent.customFormat.split('$custom')[0] + value + self.parent.customFormat.split('$custom')[1]
|
||||
else:
|
||||
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.update()
|
||||
except:
|
||||
|
@ -182,8 +182,6 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.cpuText()
|
||||
if (self.cpuclockBool > 0):
|
||||
self.cpuclockText()
|
||||
if (self.customBool > 0):
|
||||
self.getCustom()
|
||||
if (self.hddBool > 0):
|
||||
self.mountText()
|
||||
if ((self.memBool > 0) and (self.memInMb == False)):
|
||||
@ -312,15 +310,6 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.label_temp.setText(text)
|
||||
|
||||
|
||||
def getCustom(self):
|
||||
"""function to get output from custom command"""
|
||||
commandOut = commands.getoutput(self.custom_command)
|
||||
line = self.customFormat
|
||||
line = line.split('$custom')[0] + commandOut + line.split('$custom')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_custom.setText(text)
|
||||
|
||||
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update label"""
|
||||
|
@ -83,7 +83,6 @@ class Reinit():
|
||||
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.tooltipNum = settings.get('tooltip_num', 100).toInt()[0]
|
||||
self.parent.tooltipColors['cpu'] = str(settings.get('cpu_color', '#ff0000'))
|
||||
|
Reference in New Issue
Block a user