Release 1.5.0

+ added music player support
+ added copyright
* edited README
This commit is contained in:
arcan1s
2013-11-06 01:33:21 +04:00
parent 7d5803fec8
commit 4a841766e8
18 changed files with 426 additions and 69 deletions

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
#
# 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 *

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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()))

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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())

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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:

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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&deg;C]', 'hdd':'[hdd: @@/@@%]',
'hddtemp':'[hdd temp: @@/dev/sda@@&deg;C]', 'mem':'[mem: $mem%]',
'net':'[$netdev: $netKB/s]', 'swap':'[swap: $swap%]',
'temp':'[temp: $temp&deg;C]', 'uptime':'[uptime: $uptime]'}
'temp':'[temp: $temp&deg;C]', 'uptime':'[uptime: $uptime]',
'player':'[$artist - $title]'}
def showConfigurationInterface(self):
"""function to show configuration window"""

View File

@ -42,3 +42,8 @@ Action=Popup
Name=Graphical Information
Comment=Graphical Information
Action=Popup
[Event/musicplayer]
Name=Now playing
Comment=Now playing
Action=Popup

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# 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)

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
#
# 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

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>575</width>
<height>500</height>
<height>530</height>
</rect>
</property>
<property name="sizePolicy">
@ -82,7 +82,7 @@
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -138,7 +138,7 @@ $ccpu - load CPU for each core, %</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -197,7 +197,7 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -268,7 +268,7 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -326,7 +326,7 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -384,7 +384,7 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -443,7 +443,7 @@ $memmb - RAM usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -502,7 +502,7 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -560,7 +560,7 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -618,7 +618,7 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -678,7 +678,7 @@ $netdev - current network device
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -737,7 +737,7 @@ $ac - AC status</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
@ -841,6 +841,90 @@ $ac - AC status</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_player">
<item>
<widget class="QCheckBox" name="checkBox_player">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">Music player</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_player">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>amarok</string>
</property>
</item>
<item>
<property name="text">
<string>mpd</string>
</property>
</item>
<item>
<property name="text">
<string>qmmp</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_player">
<property name="toolTip">
<string notr="true">$title - song title
$artist - song artist</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="slider_player">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>13</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>13</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_elements">
<property name="orientation">
@ -1223,6 +1307,10 @@ $ac - AC status</string>
<tabstop>slider_bat</tabstop>
<tabstop>lineEdit_batdev</tabstop>
<tabstop>lineEdit_acdev</tabstop>
<tabstop>checkBox_player</tabstop>
<tabstop>comboBox_player</tabstop>
<tabstop>lineEdit_player</tabstop>
<tabstop>slider_player</tabstop>
<tabstop>spinBox_interval</tabstop>
<tabstop>fontComboBox</tabstop>
<tabstop>spinBox_fontSize</tabstop>

View File

@ -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=