diff --git a/CHANGELOG b/CHANGELOG index 5ca7280..340073f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,9 @@ -Ver.1.7.5: +Ver.1.8.0: + added scrollbar to configuration interface + added AC lines configuration + added $hddmbN, %hddgbN tags ++ added support of ps ($ps, $pscount, $pstotal tags) ++ added support of package managers ($pkgcountN tags) Ver.1.7.4: + added support more than 10 tags in cpu, cpuclock, hdd, hddtemp, temp labels diff --git a/CHANGELOG-RU b/CHANGELOG-RU index 9df3b47..96a2120 100644 --- a/CHANGELOG-RU +++ b/CHANGELOG-RU @@ -1,7 +1,9 @@ -Вер.1.7.5: +Вер.1.8.0: + добавлены скроллбары в конфигурационный интерфейс + добавлена настройка значений AC + добавлены теги $hddmbN, $hddgbN ++ добавлена поддержка ps (теги $ps, $pscount, $pstotal) ++ добавлена поддержка пакетных менеджеров (теги $pkgcountN) Вер.1.7.4: + добавлена поддержка более чем 10 тэгов в полях cpu, cpuclock, hdd, hddtemp, temp diff --git a/sources/ext-sysmon/extsysmon.cpp b/sources/ext-sysmon/extsysmon.cpp index b4833df..e3eb757 100644 --- a/sources/ext-sysmon/extsysmon.cpp +++ b/sources/ext-sysmon/extsysmon.cpp @@ -345,6 +345,11 @@ QStringList ExtendedSysMon::getPsStats() QStringList psStats; psStats.append(QString::number(psCount)); psStats.append(psList.join(QString(","))); + command.start(QString("ps -e --no-headers -o command")); + command.waitForFinished(-1); + qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed(); + int psTotal = qoutput.split(QString("\n"), QString::SkipEmptyParts).count(); + psStats.append(QString::number(psTotal)); return psStats; } @@ -448,6 +453,8 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source) setData(source, key, value[0].toInt()); key = QString("ps"); setData(source, key, value[1]); + key = QString("psTotal"); + setData(source, key, value[2].toInt()); } return true; } diff --git a/sources/ptm/contents/code/configdef.py b/sources/ptm/contents/code/configdef.py index 0079a44..9aadfde 100644 --- a/sources/ptm/contents/code/configdef.py +++ b/sources/ptm/contents/code/configdef.py @@ -76,12 +76,21 @@ class ConfigDefinition: dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf" try: with open(dataengineConfig, 'w') as deConfigFile: + deConfigFile.write("CUSTOM=" + str(self.configpage.ui.lineEdit_customCommand.text()) + "\n") 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") - deConfigFile.write("PKGCMD=" + str(self.configpage.ui.comboBox_pkgCommand.currentText()) + "\n") + item = QStringList() + for i in range(self.configpage.ui.listWidget_pkgCommand.count()): + item.append(self.configpage.ui.listWidget_pkgCommand.item(i).text()) + pkgCmd = [] + pkgNull = [] + for command in item: + pkgCmd.append(str(command.split(QString(":"))[0])) + pkgNull.append(str(command.split(QString(":"))[1])) + deConfigFile.write("PKGCMD=" + ','.join(pkgCmd) + "\n") + deConfigFile.write("PKGNULL=" + ','.join(pkgNull) + "\n") except: pass @@ -173,8 +182,8 @@ 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', 'PKGCMD':'pacman -Qu'} + deSettings = {'CUSTOM':'wget -qO- http://ifconfig.me/ip', 'GPUDEV':'auto', 'HDDDEV':'all', + 'MPDADDRESS':'localhost', 'MPDPORT':'6600', 'PKGCMD':'pacman -Qu', 'PKGNULL':'0'} dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf" try: with open(dataengineConfig, 'r') as deConfigFile: @@ -183,6 +192,7 @@ class ConfigDefinition: deSettings[line.split('=')[0]] = line.split('=')[1][:-1] except: pass + self.configpage.ui.lineEdit_customCommand.setText(deSettings['CUSTOM']) index = self.configpage.ui.comboBox_gpudev.findText(deSettings['GPUDEV']) self.configpage.ui.comboBox_gpudev.setCurrentIndex(index) self.configpage.ui.comboBox_hdddev.addItem("all") @@ -197,9 +207,13 @@ class ConfigDefinition: 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']) - index = self.configpage.ui.comboBox_pkgCommand.findText(deSettings['PKGCMD']) - self.configpage.ui.comboBox_pkgCommand.setCurrentIndex(index) + self.configpage.ui.listWidget_pkgCommand.clear() + for i in range(len(deSettings['PKGCMD'].split(','))): + try: + num = deSettings['PKGNULL'].split(',')[i] + except: + num = "0" + self.configpage.ui.listWidget_pkgCommand.addItem(deSettings['PKGCMD'].split(',')[i] + ':' + num) labelOrder = str(settings.get('label_order', '1345')) for label in self.defaults['order'].keys(): diff --git a/sources/ptm/contents/code/configwindow.py b/sources/ptm/contents/code/configwindow.py index 745f6b1..c720132 100644 --- a/sources/ptm/contents/code/configwindow.py +++ b/sources/ptm/contents/code/configwindow.py @@ -66,9 +66,13 @@ class ConfigWindow(QWidget): 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.pushButton_pkgCommand, SIGNAL("clicked()"), self.addPkgCommand) 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) + QObject.connect(self.ui.listWidget_pkgCommand, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_pkgCommand.openPersistentEditor) + QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("currentIndexChanged(int)"), self.updatePkgNullValue) + QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("editTextChanged(QString)"), self.updatePkgNullValue) for item in self.sliders.values(): QObject.connect(item, SIGNAL("valueChanged(int)"), self.setSlider) for item in self.checkboxes.values(): @@ -87,6 +91,9 @@ class ConfigWindow(QWidget): elif (self.ui.listWidget_tempDevice.hasFocus() and (self.ui.listWidget_tempDevice.currentRow() > -1)): self.ui.listWidget_tempDevice.takeItem(self.ui.listWidget_tempDevice.currentRow()) + elif (self.ui.listWidget_pkgCommand.hasFocus() and + (self.ui.listWidget_pkgCommand.currentRow() > -1)): + self.ui.listWidget_pkgCommand.takeItem(self.ui.listWidget_pkgCommand.currentRow()) def addHddDevice(self): @@ -107,6 +114,29 @@ class ConfigWindow(QWidget): self.ui.listWidget_tempDevice.addItem(self.ui.comboBox_tempDevice.currentText()) + def addPkgCommand(self): + """function to add package manager command""" + self.ui.listWidget_pkgCommand.clearSelection() + self.ui.listWidget_pkgCommand.addItem(self.ui.comboBox_pkgCommand.currentText() +\ + QString(":") + QString.number(self.ui.spinBox_pkgCommandNum.value())) + + + def updatePkgNullValue(self): + """function to set default values to PKGNULL spinbox""" + if (self.ui.comboBox_pkgCommand.currentText().contains(QString("pacman -Qu"))): + self.ui.spinBox_pkgCommandNum.setValue(0) + elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("apt-show-versions -u -b"))): + self.ui.spinBox_pkgCommandNum.setValue(0) + elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("aptitude search '~U'"))): + self.ui.spinBox_pkgCommandNum.setValue(0) + elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("yum list updates"))): + self.ui.spinBox_pkgCommandNum.setValue(3) + elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("pkg_version -I -l '<'"))): + self.ui.spinBox_pkgCommandNum.setValue(0) + elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("urpmq --auto-select"))): + self.ui.spinBox_pkgCommandNum.setValue(0) + + def setNetdevEnabled(self): """function to set enabled netdev""" if (self.ui.checkBox_netdev.checkState() == 0): diff --git a/sources/ptm/contents/code/dataengine.py b/sources/ptm/contents/code/dataengine.py index 1476eb1..d389e97 100644 --- a/sources/ptm/contents/code/dataengine.py +++ b/sources/ptm/contents/code/dataengine.py @@ -64,11 +64,12 @@ class DataEngine: self.updateNetdev = 0 dataEngines['system'].connectSource("network/interfaces/" + names['net'] + "/transmitter/data", self.parent, interval) dataEngines['system'].connectSource("network/interfaces/" + names['net'] + "/receiver/data", self.parent, interval) + if (bools['pkg'] > 0): + dataEngines['ext'].connectSource("pkg", 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) + dataEngines['ext'].connectSource("ps", 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) @@ -116,11 +117,11 @@ class DataEngine: updatedData['value'] = value elif (sourceName == "gpu"): updatedData['name'] = "gpu" - value = round(data[QString(u'GPU')].toFloat()[0], 1) + value = round(data[QString(u'GPU')], 1) updatedData['value'] = "%4.1f" % (value) elif (sourceName == "gputemp"): updatedData['name'] = "gputemp" - value = round(data[QString(u'GPUTemp')].toFloat()[0], 1) + value = round(data[QString(u'GPUTemp')], 1) updatedData['value'] = "%4.1f" % (value) elif (sourceName.split('/')[0] == "partitions") and (sourceName.split('/')[-1] == "filllevel"): updatedData['name'] = "hdd" @@ -136,7 +137,7 @@ class DataEngine: updatedData['name'] = "hddtemp" updatedData['value'] = {} for item in names['hddtemp']: - value = round(data[QString(item)].toFloat()[0], 1) + value = round(data[QString(item)], 1) updatedData['value'][item] = "%4.1f" % (value) elif (sourceName == "mem/physical/application"): updatedData['name'] = "mem" @@ -173,6 +174,11 @@ class DataEngine: updatedData['type'] = "up" value = round(data[QString(u'value')].toFloat()[0], 0) updatedData['value'] = value + elif (sourceName == "pkg"): + updatedData['name'] = "pkg" + updatedData['value'] = {} + for singleData in data.keys(): + updatedData['value'][str(singleData.toLower())] = "%i" % (data[singleData]) elif (sourceName == "player"): updatedData['name'] = "player" updatedData['value'] = {} @@ -195,16 +201,11 @@ class DataEngine: 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 + updatedData['value'] = {} + updatedData['value']['num'] = data[QString(u'psCount')] + updatedData['value']['total'] = data[QString(u'psTotal')] + updatedData['value']['list'] = data[QString(u'ps')] elif (sourceName == "mem/swap/free"): updatedData['name'] = "swap" updatedData['type'] = "free" @@ -297,11 +298,12 @@ class DataEngine: elif (name == "net"): dataEngines['system'].disconnectSource("network/interfaces/" + keys['net'] + "/transmitter/data", self.parent) dataEngines['system'].disconnectSource("network/interfaces/" + keys['net'] + "/receiver/data", self.parent) + elif (name == "pkg"): + dataEngines['ext'].disconnectSource("pkg", 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) + dataEngines['ext'].disconnectSource("ps", self.parent) elif (name == "swap"): dataEngines['system'].disconnectSource("mem/swap/used", self.parent) dataEngines['system'].disconnectSource("mem/swap/free", self.parent) diff --git a/sources/ptm/contents/code/main.py b/sources/ptm/contents/code/main.py index 9d376d2..9553dbc 100644 --- a/sources/ptm/contents/code/main.py +++ b/sources/ptm/contents/code/main.py @@ -150,7 +150,7 @@ class pyTextWidget(plasmascript.Applet): '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]', 'pkg':'[upgrade: $pkgcount]', + 'net':'[$netdev: $down/$upKB/s]', 'pkg':'[upgrade: $pkgcount0]', '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', @@ -185,8 +185,6 @@ class pyTextWidget(plasmascript.Applet): self.ptm['values']['hddtemp'] = {} 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 @@ -229,8 +227,6 @@ 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): @@ -254,15 +250,14 @@ class pyTextWidget(plasmascript.Applet): updatedData = self.dataengine.dataUpdated(str(sourceName), data, self.ptm) if (updatedData['value'] == None): return - # update falues where is needed + # update values where is needed if (updatedData['type'] != None): self.ptm['values'][updatedData['name']][updatedData['type']] = updatedData['value'] - else: - self.ptm['values'][updatedData['name']] = updatedData['value'] - # update labels where is needed - if (updatedData['name'] in ['custom', 'gpu', 'gputemp', 'player', 'time', 'uptime']): + elif (updatedData['name'] in ['custom', 'gpu', 'gputemp', 'pkg', 'player', 'ps', 'time', 'uptime']): text = self.textPrepare(updatedData['name'], updatedData['value']) self.setText(updatedData['name'], text) + else: + self.ptm['values'][updatedData['name']] = updatedData['value'] # update tooltips if ((updatedData['name'] in ['cpu', 'cpuclock', 'mem', 'swap', 'net']) and (self.ptm['vars']['bools'][updatedData['name']] == 2)): if (updatedData['name'] == "net"): @@ -420,16 +415,6 @@ 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'] @@ -556,17 +541,30 @@ class pyTextWidget(plasmascript.Applet): elif (name == "gputemp"): if (line.split('$gputemp')[0] != line): line = line.split('$gputemp')[0] + text + line.split('$gputemp')[1] + elif (name == "pkg"): + for item in text.keys(): + if (line.split('$' + item)[0] != line): + line = line.split('$' + item)[0] + text[item] + line.split('$' + item)[1] elif (name == "player"): if (line.split('$album')[0] != line): - line = line.split('$album')[0] + self.ptm['values']['player']['album'] + line.split('$album')[1] + line = line.split('$album')[0] + text['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] + line = line.split('$artist')[0] + text['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] + line = line.split('$progress')[0] + text['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] + line = line.split('$time')[0] + text['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] + line = line.split('$title')[0] + text['title'] + line.split('$title')[1] + elif (name == "ps"): + if (line.split('$pscount')[0] != line): + ps = "%i" % (text['num']) + line = line.split('$pscount')[0] + ps + line.split('$pscount')[1] + if (line.split('$pstotal')[0] != line): + ps = "%i" % (text['total']) + line = line.split('$pstotal')[0] + ps + line.split('$pstotal')[1] + if (line.split('$ps')[0] != line): + line = line.split('$ps')[0] + text['list'] + line.split('$ps')[1] elif (name == "time"): if (line.split('$time')[0] != line): line = line.split('$time')[0] + text + line.split('$time')[1] diff --git a/sources/ptm/contents/ui/configwindow.ui b/sources/ptm/contents/ui/configwindow.ui index fd80e5e..5f4b5f8 100644 --- a/sources/ptm/contents/ui/configwindow.ui +++ b/sources/ptm/contents/ui/configwindow.ui @@ -64,7 +64,7 @@ 0 - 0 + -105 526 624 @@ -933,25 +933,19 @@ $title - song title - PS + Processes true - - true - - $cpu - total load CPU, % -$cpu0 - load CPU for core 0, % -... -$cpu9 - load CPU for core 9, % -... -$cpuN - load CPU for core N, % + $pscount - number of running processes +$pstotal - total number of running processes +$ps - list of running processes comma separated Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -1004,20 +998,12 @@ $cpuN - load CPU for core N, % true - - true - - $cpu - total load CPU, % -$cpu0 - load CPU for core 0, % -... -$cpu9 - load CPU for core 9, % -... -$cpuN - load CPU for core N, % + $pkgcountN - number of packages which are available for updates, command N. For example $pkgcount0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2329,6 +2315,33 @@ del - remove item + + + + + + + 120 + 0 + + + + Custom command + + + + + + + Custom command to run + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + @@ -2490,78 +2503,116 @@ del - remove item - + - - - - 120 - 0 - - - - Custom command - - + + + + + + 120 + 0 + + + + Package manager + + + + + + + + 0 + 0 + + + + true + + + + pacman -Qu + + + + + apt-show-versions -u -b + + + + + aptitude search '~U' + + + + + yum list updates + + + + + pkg_version -I -l '<' + + + + + urpmq --auto-select + + + + + - + + + + + + 120 + 0 + + + + Number of null lines + + + + + + + + 0 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 100 + 0 + + + + Add + + + + + + + - Custom command to run + Editable +del - remove item - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 120 - 0 - - - - Package manager - - - - - - - - 0 - 0 - - - - true - - - - pacman -Qu - - - - - apt-show-versions -u -b - - - - - aptitude search '~U' - - - - - yum list updates - - @@ -2686,11 +2737,11 @@ del - remove item comboBox_style spinBox_weight scrollArea_dattaengine + lineEdit_customCommand comboBox_gpudev comboBox_hdddev lineEdit_mpdaddress spinBox_mpdport - lineEdit_customCommand