diff --git a/PKGBUILD b/PKGBUILD index 76cdd69..468ef20 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,24 +3,27 @@ pkgname=kdeplasma-applets-pytextmonitor _pkgname=py-text-monitor -pkgver=1.4.0 +pkgver=1.5.0 pkgrel=1 _dtengine=ext-sysmon -_dtver=1.2 +_dtver=1.3 pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm" arch=('i686' 'x86_64') url="https://github.com/arcan1s/pytextmonitor" license=('GPL') -depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools') +depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools' 'sysstat') optdepends=("hddtemp: for HDD temperature monitor" "catalyst: for GPU monitor" - "nvidia-utils: for GPU monitor") + "nvidia-utils: for GPU monitor" + "amarok: for music player monitor" + "mpd: for music player monitor" + "qmmp: for music player monitor") makedepends=('automoc4' 'cmake') source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}.plasmoid https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_dtengine}-${_dtver}.zip) install=${pkgname}.install -md5sums=('67f3e3b55992048bd519867a9e94da37' - '3182acdadb3b498be929b3cadad92206') +md5sums=('df8e9f6df8e7b3caee3a502315756d81' + 'f7fce53d5f616891b30beac1afd99728') build () { diff --git a/README b/README deleted file mode 100644 index 8b99435..0000000 --- a/README +++ /dev/null @@ -1,36 +0,0 @@ -py-text-monitor -============= - -PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm. - -HOWTO -For edited output you must open Settings window and setup output format in lines: - label "$uptime" means uptime, ---d--h--m - label "$cpu" means total load cpu, % - label "$ccpu" means load CPU for each core, % - label "$cpucl" - average cpu clock, MHz - label "$ccpucl" - cpu clock for each core, MHz - label "$temp" - average temperature in system - label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed - label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed - label "$mem" - usage memory, % - label "$memmb" - usage memory, MB - label "$swap" - swap, % - label "$swapmb" - swap, MB - label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed - label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature - label "$net" - download and upload speed, KB/s. You may specify network device: something like @@eth0@@ - label "$netdev" - current network device - label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent - label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online - -Label order will changed if you change slider position. HTML tags in label work normally. -Attention: you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label. - - -Dependencies: - kdebindings-python2 - - ext-sysmon (for GPU, GPU temp and HDD temp labels) - lm_sensors (for definition temperature device) - net-tools (for definition network device) diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcb305b --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +py-text-monitor +============= + +Information +----------- +PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm. + +Configuration +------------- +For edited output you must open Settings window and setup output format in lines: +* label "$uptime" means uptime, ---d--h--m +* label "$cpu" means total load cpu, % +* label "$ccpu" means load CPU for each core, % +* label "$cpucl" - average cpu clock, MHz +* label "$ccpucl" - cpu clock for each core, MHz +* label "$temp" - average temperature in system +* label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed +* label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed +* label "$mem" - usage memory, % +* label "$memmb" - usage memory, MB +* label "$swap" - swap, % +* label "$swapmb" - swap, MB +* label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed +* label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature +* label "$net" - download and upload speed, KB/s. You may specify network device: something like @@eth0@@ +* label "$netdev" - current network device +* label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent +* label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online +* label "$artist" - current song artist. One of supported music players must be installed +* label "$title" - current song title. One of supported music players must be installed + +Label order will changed if you change slider position. HTML tags in label work normally. +**NOTE** you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label. + +TODO (wish) list +---------------- +* Tooltip (graphical information): +* * cpu, % +* * cpuclock, mhz +* * memory, % +* * swap, % +* * network, % + +Instruction +=========== + +Dependencies +------------ +* kdebase-workspace +* kdebindings-python2 +* lm_sensors (for definition temperature device) +* net-tools (for definition network device) +* sysstat (for notification) + +Optional dependencies +--------------------- +* ext-sysmon (for GPU, GPU temp, HDD temp and player labels) +* * proprietary video driver +* * hddtemp +* * music player (amarok, mpd or qmmp) + +Make dependencies +----------------- +* automoc4 +* cmake + +Installation +------------ +* download sources +* install dataengine + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../ + make && make install +Also you may install it to "/": + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../ + make && sudo make install +* install plasmoid + plasmapkg -i py-text-monitor-1.5.0.plasmoid +Also you may install it to "/" too: + plasmapkg -g -i py-text-monitor-1.5.0.plasmoid + +Additional information +====================== + +Links +----- +* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124) +* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773) +* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/) package diff --git a/TODO b/TODO deleted file mode 100644 index f46f42f..0000000 --- a/TODO +++ /dev/null @@ -1,6 +0,0 @@ -1. Tooltip (graphical information): - a) cpu, % - b) cpuclock, mhz - c) memory, % - d) swap, % - e) network, % diff --git a/ext-sysmon-1.3.zip b/ext-sysmon-1.3.zip new file mode 100644 index 0000000..403e0f0 Binary files /dev/null and b/ext-sysmon-1.3.zip differ diff --git a/py-text-monitor-1.4.0.plasmoid b/old_versions/py-text-monitor-1.4.0.plasmoid similarity index 100% rename from py-text-monitor-1.4.0.plasmoid rename to old_versions/py-text-monitor-1.4.0.plasmoid diff --git a/py-text-monitor-1.5.0.plasmoid b/py-text-monitor-1.5.0.plasmoid new file mode 100644 index 0000000..b30895e Binary files /dev/null and b/py-text-monitor-1.5.0.plasmoid differ diff --git a/sources/contents/code/config.py b/sources/contents/code/config.py index b2a2912..03ccc26 100644 --- a/sources/contents/code/config.py +++ b/sources/contents/code/config.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2012 Alex Oleshkevich +# +# 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 * diff --git a/sources/contents/code/configdef.py b/sources/contents/code/configdef.py index fef6d46..e8d8caa 100644 --- a/sources/contents/code/configdef.py +++ b/sources/contents/code/configdef.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyQt4.QtGui import * from PyKDE4.kdecore import * from PyKDE4.kdeui import * @@ -117,8 +133,11 @@ class ConfigDefinition: if (self.parent.batBool > 0): self.parent.label_bat.setText('') self.parent.layout.removeItem(self.parent.label_bat) + if (self.parent.playerBool > 0): + self.parent.label_player.setText('') + self.parent.layout.removeItem(self.parent.label_player) - 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())) @@ -140,6 +159,9 @@ class ConfigDefinition: 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) self.parent.label_order = ''.join(self.parent.label_order.split('-')) settings.set('label_order', self.parent.label_order) @@ -186,6 +208,8 @@ class ConfigDefinition: 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())) diff --git a/sources/contents/code/configwindow.py b/sources/contents/code/configwindow.py index e218dec..15e36d6 100644 --- a/sources/contents/code/configwindow.py +++ b/sources/contents/code/configwindow.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyQt4.QtCore import * from PyQt4.QtGui import * from PyKDE4.plasma import * @@ -19,19 +35,22 @@ class ConfigWindow(QWidget): '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} + 'temp':self.ui.checkBox_temp, 'uptime':self.ui.checkBox_uptime, + 'player':self.ui.checkBox_player} 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} + 'temp':self.ui.slider_temp, 'uptime':self.ui.slider_uptime, + 'player':self.ui.slider_player} 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} + 'temp':self.ui.lineEdit_temp, 'uptime':self.ui.lineEdit_uptime, + 'player':self.ui.lineEdit_player} for item in self.checkboxes.values(): QObject.connect(item, SIGNAL("stateChanged(int)"), self.setStatus) @@ -51,6 +70,8 @@ class ConfigWindow(QWidget): 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): @@ -69,6 +90,8 @@ class ConfigWindow(QWidget): 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()) diff --git a/sources/contents/code/dataengine.py b/sources/contents/code/dataengine.py index b4b4669..8f5e924 100644 --- a/sources/contents/code/dataengine.py +++ b/sources/contents/code/dataengine.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyQt4.QtCore import * from PyQt4.QtGui import * from PyKDE4.plasma import Plasma @@ -16,7 +32,7 @@ class DataEngine: def connectToEngine(self): """function to initializate engine""" self.parent.systemmonitor = self.parent.dataEngine("systemmonitor") - if ((self.parent.gputempBool > 0) or (self.parent.gpuBool > 0) or (self.parent.hddtempBool > 0)): + if ((self.parent.gputempBool > 0) or (self.parent.gpuBool > 0) or (self.parent.hddtempBool > 0) or (self.parent.playerBool > 0)): self.parent.extsysmon = self.parent.dataEngine("ext-sysmon") if (self.parent.uptimeBool > 0): @@ -59,6 +75,8 @@ class DataEngine: self.parent.updateNetdev = 0 self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval) 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) def dataUpdated(self, sourceName, data): """function to update data""" @@ -231,6 +249,28 @@ class DataEngine: line = self.parent.hddtempFormat text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] self.parent.label_hddtemp.setText(text) + elif (sourceName == "player"): + if (self.parent.player_name == 0): + title = str(data[QString(u'amarok_title')]) + artist = str(data[QString(u'amarok_artist')]) + elif (self.parent.player_name == 1): + title = str(data[QString(u'mpd_title')]) + artist = str(data[QString(u'mpd_artist')]) + elif (self.parent.player_name == 2): + title = str(data[QString(u'qmmp_title')]) + artist = str(data[QString(u'qmmp_artist')]) + if (self.parent.playerFormat.split('$artist')[0] != self.parent.playerFormat): + if ((len(artist) + len(title)) > 10): + line = self.parent.playerFormat.split('$artist')[0] + artist[:5] + u"…" + self.parent.playerFormat.split('$artist')[1] + else: + line = self.parent.playerFormat.split('$artist')[0] + artist + self.parent.playerFormat.split('$artist')[1] + else: + line = self.parent.playerFormat + if (line.split('$title') != line): + line = line.split('$title')[0] + title + line.split('$title')[1] + text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1] + self.parent.label_player.setText(text) + self.parent.update() except: diff --git a/sources/contents/code/main.py b/sources/contents/code/main.py index b7333d6..f5a2b8e 100644 --- a/sources/contents/code/main.py +++ b/sources/contents/code/main.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyQt4.QtCore import * from PyQt4.QtGui import * from PyKDE4.kdecore import * @@ -103,13 +119,15 @@ class pyTextWidget(plasmascript.Applet): # 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'} + 'b':'hdd', 'c':'hddtemp', '3':'mem', '5':'net', '4':'swap', '2':'temp', '8':'uptime', + 'd':'player'} 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%]', 'net':'[$netdev: $netKB/s]', 'swap':'[swap: $swap%]', - 'temp':'[temp: $temp°C]', 'uptime':'[uptime: $uptime]'} + 'temp':'[temp: $temp°C]', 'uptime':'[uptime: $uptime]', + 'player':'[$artist - $title]'} def showConfigurationInterface(self): """function to show configuration window""" diff --git a/sources/contents/code/plasma_applet_pytextmonitor.notifyrc b/sources/contents/code/plasma_applet_pytextmonitor.notifyrc index a6530d8..f62ff3a 100644 --- a/sources/contents/code/plasma_applet_pytextmonitor.notifyrc +++ b/sources/contents/code/plasma_applet_pytextmonitor.notifyrc @@ -42,3 +42,8 @@ Action=Popup Name=Graphical Information Comment=Graphical Information Action=Popup + +[Event/musicplayer] +Name=Now playing +Comment=Now playing +Action=Popup diff --git a/sources/contents/code/ptmnotify.py b/sources/contents/code/ptmnotify.py index 991a199..ba980c7 100644 --- a/sources/contents/code/ptmnotify.py +++ b/sources/contents/code/ptmnotify.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyKDE4.kdecore import KComponentData from PyKDE4.kdeui import KNotification import commands @@ -132,6 +148,31 @@ class PTMNotify: text = text + "%s" %(commands.getoutput("acpi -abi")) except: text = "Something wrong" + elif (type == "musicplayer"): + try: + artist = "N\\A" + album = "N\\A" + title = "N\\A" + if (self.parent.parent.player_name == 0): + artist = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-") + album = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep album: | cut -c8-") + title = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep title: | cut -c8-") + elif (self.parent.parent.player_name == 1): + output = commands.getoutput("echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://localhost:6600 2> /dev/null") + for line in output.split("\n"): + if (line.split(": ")[0] == "Artist"): + artist = line.split(": ")[1] + elif (line.split(": ")[0] == "Album"): + album = line.split(": ")[1] + elif (line.split(": ")[0] == "Title"): + title = line.split(": ")[1] + elif (self.parent.parent.player_name == 2): + artist = commands.getoutput("qmmp --nowplaying '%if(%p,%p,Unknown)' 2> /dev/null") + album = commands.getoutput("qmmp --nowplaying '%if(%a,%a,Unknown)' 2> /dev/null") + title = commands.getoutput("qmmp --nowplaying '%if(%t,%t,Unknown)' 2> /dev/null") + text = text + "Artist: %s\nAlbum: %s\nTitle: %s" %(artist, album, title) + except: + text = "Something wrong" content = [type, text] return content @@ -211,3 +252,9 @@ class PTMNotify: return content except: pass + try: + if (sender == self.parent.parent.label_player): + content = self.createText("musicplayer") + return content + except: + pass diff --git a/sources/contents/code/reinit.py b/sources/contents/code/reinit.py index 49bf25c..83aee8c 100644 --- a/sources/contents/code/reinit.py +++ b/sources/contents/code/reinit.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2013 Evgeniy Alekseev +# +# 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 PyQt4.QtCore import * from PyQt4.QtGui import * from PyKDE4.plasma import Plasma @@ -277,6 +293,20 @@ class Reinit(): 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) + if (self.parent.playerFormat.split('$artist')[0] != self.parent.playerFormat): + line = self.parent.playerFormat.split('$artist')[0] + '----------' + self.parent.playerFormat.split('$artist')[1] + else: + line = self.parent.playerFormat + if (line.split('$title') != line): + line = line.split('$title')[0] + '----------' + line.split('$title')[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) if not confAccept: self.parent.applet.setLayout(self.parent.layout) self.parent.theme = Plasma.Svg(self.parent) diff --git a/sources/contents/code/util.py b/sources/contents/code/util.py index c2ac27c..015af14 100644 --- a/sources/contents/code/util.py +++ b/sources/contents/code/util.py @@ -1,5 +1,21 @@ # -*- coding: utf-8 -*- +# Copyright 2012 Alex Oleshkevich +# +# 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 * import os diff --git a/sources/contents/ui/configwindow.ui b/sources/contents/ui/configwindow.ui index 968161b..62c6973 100644 --- a/sources/contents/ui/configwindow.ui +++ b/sources/contents/ui/configwindow.ui @@ -7,7 +7,7 @@ 0 0 575 - 500 + 530 @@ -82,7 +82,7 @@ 1 - 12 + 13 1 @@ -138,7 +138,7 @@ $ccpu - load CPU for each core, % 1 - 12 + 13 1 @@ -197,7 +197,7 @@ $ccpucl - CPU clock for each core, MHz 1 - 12 + 13 1 @@ -268,7 +268,7 @@ $ccpucl - CPU clock for each core, MHz 1 - 12 + 13 1 @@ -326,7 +326,7 @@ $ccpucl - CPU clock for each core, MHz 1 - 12 + 13 1 @@ -384,7 +384,7 @@ $ccpucl - CPU clock for each core, MHz 1 - 12 + 13 1 @@ -443,7 +443,7 @@ $memmb - RAM usage, MB 1 - 12 + 13 1 @@ -502,7 +502,7 @@ $swapmb - swap usage, MB 1 - 12 + 13 1 @@ -560,7 +560,7 @@ $swapmb - swap usage, MB 1 - 12 + 13 1 @@ -618,7 +618,7 @@ $swapmb - swap usage, MB 1 - 12 + 13 1 @@ -678,7 +678,7 @@ $netdev - current network device 1 - 12 + 13 1 @@ -737,7 +737,7 @@ $ac - AC status 1 - 12 + 13 1 @@ -841,6 +841,90 @@ $ac - AC status + + + + + + + 120 + 0 + + + + Music player + + + true + + + + + + + + 100 + 0 + + + + + amarok + + + + + mpd + + + + + qmmp + + + + + + + + $title - song title +$artist - song artist + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 120 + 16777215 + + + + 1 + + + 13 + + + 1 + + + 13 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + @@ -1223,6 +1307,10 @@ $ac - AC status slider_bat lineEdit_batdev lineEdit_acdev + checkBox_player + comboBox_player + lineEdit_player + slider_player spinBox_interval fontComboBox spinBox_fontSize diff --git a/sources/metadata.desktop b/sources/metadata.desktop index 6b64ef9..6af43e4 100644 --- a/sources/metadata.desktop +++ b/sources/metadata.desktop @@ -12,7 +12,7 @@ X-Plasma-RequiredExtensions=LaunchApp,LocalIO,FileDialog X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Name=py-text-monitor -X-KDE-PluginInfo-Version=1.4.0 +X-KDE-PluginInfo-Version=1.5.0 X-KDE-PluginInfo-Website=http://kde-look.org/ X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends=