Release 1.4.0

+ added notification
* small refactoring
This commit is contained in:
arcan1s 2013-10-22 16:22:39 +04:00
parent d55d478243
commit 6c9a167aa2
13 changed files with 106 additions and 37 deletions

View File

@ -3,7 +3,7 @@
pkgname=kdeplasma-applets-pytextmonitor pkgname=kdeplasma-applets-pytextmonitor
_pkgname=py-text-monitor _pkgname=py-text-monitor
pkgver=1.3.6 pkgver=1.4.0
pkgrel=1 pkgrel=1
_dtengine=ext-sysmon _dtengine=ext-sysmon
_dtver=1.2 _dtver=1.2
@ -19,8 +19,8 @@ makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}.plasmoid 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) https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_dtengine}-${_dtver}.zip)
install=${pkgname}.install install=${pkgname}.install
md5sums=('de54ece6545d28888a60d33f09ce69a1' md5sums=('988704016573b215bb36b62762075fee'
'775bc3a6057f2dc1696f09b8d315a3e9') '3182acdadb3b498be929b3cadad92206')
build () build ()
{ {
@ -42,6 +42,8 @@ package()
make DESTDIR="${pkgdir}" install make DESTDIR="${pkgdir}" install
# install plasmoid # install plasmoid
install -D -m644 "${srcdir}/contents/code/plasma_applet_pytextmonitor.notifyrc" \
"${pkgdir}/`kde4-config --prefix`/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"
install -D -m644 "${srcdir}/metadata.desktop" \ install -D -m644 "${srcdir}/metadata.desktop" \
"${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop" "${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop"
install -D -m644 "${srcdir}/metadata.desktop" \ install -D -m644 "${srcdir}/metadata.desktop" \

2
TODO
View File

@ -3,4 +3,4 @@
b) cpuclock, mhz b) cpuclock, mhz
c) memory, % c) memory, %
d) swap, % d) swap, %
f) network, % e) network, %

View File

@ -15,7 +15,7 @@ sed -i "s/_dtver=[0-9.]*/_dtver=${VERSION}/" PKGBUILD
# build widget # build widget
cd sources cd sources
FILES="contents metadata.desktop" FILES="contents metadata.desktop plasma_applet_pytextmonitor"
ARCHIVE="py-text-monitor" ARCHIVE="py-text-monitor"
VERSION=`grep Version metadata.desktop | awk -F "=" '{print $2}'` VERSION=`grep Version metadata.desktop | awk -F "=" '{print $2}'`
# create archive # create archive

Binary file not shown.

View File

@ -1,9 +1,14 @@
post_install() func_update()
{ {
cat << EOF cat << EOF
Update plasmoids... Update plasmoids...
EOF EOF
kbuildsycoca4 > /dev/null 2>&1 kbuildsycoca4 > /dev/null 2>&1
}
post_install()
{
func_update
cat << EOF cat << EOF
Make sure that \`hddtemp\` can be run as non-root Make sure that \`hddtemp\` can be run as non-root
EOF EOF
@ -11,10 +16,10 @@ EOF
post_upgrade() post_upgrade()
{ {
post_install func_update
} }
post_remove() post_remove()
{ {
post_install func_update
} }

Binary file not shown.

View File

@ -7,7 +7,7 @@ from PyKDE4.kdeui import *
from PyKDE4.kio import * from PyKDE4.kio import *
from PyKDE4 import plasmascript from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma from PyKDE4.plasma import Plasma
import commands, os, time import commands, os, shutil, time
import configdef import configdef
import configwindow import configwindow
@ -39,6 +39,11 @@ class pyTextWidget(plasmascript.Applet):
self.reinit.reinit(confAccept=False) self.reinit.reinit(confAccept=False)
self.setHasConfigurationInterface(True) self.setHasConfigurationInterface(True)
# Create notifyrc file if required
kdehome = unicode(KGlobal.dirs().localkdedir())
if ((not os.path.exists(kdehome + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc")) or
(not os.path.exists("/usr" + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"))):
self.createNotifyrc(kdehome)
def createConfigurationInterface(self, parent): def createConfigurationInterface(self, parent):
@ -48,6 +53,14 @@ class pyTextWidget(plasmascript.Applet):
self.configdef.createConfigurationInterface(parent) self.configdef.createConfigurationInterface(parent)
def createNotifyrc(self, kdehome):
"""function to create *.notifyrc"""
if (not os.path.isdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")):
os.mkdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")
shutil.copy(kdehome + "/share/apps/plasma/plasmoids/py-text-monitor/contents/code/plasma_applet_pytextmonitor.notifyrc",
kdehome + "/share/apps/plasma_applet_pytextmonitor/")
def initTooltip(self): def initTooltip(self):
"""function to create tooltip""" """function to create tooltip"""
self.tooltip = Plasma.ToolTipContent() self.tooltip = Plasma.ToolTipContent()
@ -186,4 +199,4 @@ class pyTextWidget(plasmascript.Applet):
def CreateApplet(parent): def CreateApplet(parent):
return pyTextWidget(parent) return pyTextWidget(parent)

View File

@ -37,3 +37,8 @@ Action=Popup
Name=Battery information Name=Battery information
Comment=Battery information Comment=Battery information
Action=Popup Action=Popup
[Event/graphinfo]
Name=Graphical Information
Comment=Graphical Information
Action=Popup

View File

@ -37,12 +37,13 @@ class PTMNotify:
text = text + "Whoami: %s\n" %(commands.getoutput("whoami")) text = text + "Whoami: %s\n" %(commands.getoutput("whoami"))
text = text + "Uptime: %s\n" %(commands.getoutput("uptime")) text = text + "Uptime: %s\n" %(commands.getoutput("uptime"))
except: except:
pass text = "Something wrong"
elif (type == "processor"): elif (type == "processor"):
try: try:
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1") output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
text = text + "Model: %s\n" %(' '.join(output.split()[3:])) text = text + "Model: %s\n" %(' '.join(output.split()[3:]))
output = commands.getoutput("sar -u | tail -1") output = commands.getoutput("sar -u | tail -1")
print "1"
text = text + "CPU Usage: %s%%\n" %(str(100-float(output.split()[-1]))) text = text + "CPU Usage: %s%%\n" %(str(100-float(output.split()[-1])))
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1") output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
text = text + "CPU Freq: %s MHz\n" %(str(int(float(output.split()[-1])))) text = text + "CPU Freq: %s MHz\n" %(str(int(float(output.split()[-1]))))
@ -52,7 +53,7 @@ class PTMNotify:
if (line.find("_input") > -1): if (line.find("_input") > -1):
text = text + " %s\xb0C" %(str(round(float(line.split()[-1]), 0))) text = text + " %s\xb0C" %(str(round(float(line.split()[-1]), 0)))
except: except:
pass text = "Something wrong"
elif (type == "graphical"): elif (type == "graphical"):
try: try:
output = commands.getoutput("lspci -m | grep 'VGA\|3D'") output = commands.getoutput("lspci -m | grep 'VGA\|3D'")
@ -93,7 +94,7 @@ class PTMNotify:
value = " N\A" value = " N\A"
text = text + "Temp: %s\xb0C\n" %(value) text = text + "Temp: %s\xb0C\n" %(value)
except: except:
pass text = "Something wrong"
elif (type == "memory"): elif (type == "memory"):
try: try:
output = commands.getoutput("free -m -o").split("\n") output = commands.getoutput("free -m -o").split("\n")
@ -103,14 +104,14 @@ class PTMNotify:
output = commands.getoutput("swapon --show").split("\n") output = commands.getoutput("swapon --show").split("\n")
text = text + "Swap Device: %s (%s)" %(output[1].split()[0], output[1].split()[1]) text = text + "Swap Device: %s (%s)" %(output[1].split()[0], output[1].split()[1])
except: except:
pass text = "Something wrong"
elif (type == "disk"): elif (type == "disk"):
try: try:
output = commands.getoutput("df -h --output='source,target,used,size,pcent' --exclude-type=fuseblk --exclude-type=tmpfs --exclude-type=devtmpfs").split("\n")[1:] output = commands.getoutput("df -h --output='source,target,used,size,pcent' --exclude-type=fuseblk --exclude-type=tmpfs --exclude-type=devtmpfs").split("\n")[1:]
for line in output: for line in output:
text = text + "%s (to %s): %s of %s (%s)\n" %(line.split()[0], line.split()[1], line.split()[2], line.split()[3], line.split()[4]) text = text + "%s (to %s): %s of %s (%s)\n" %(line.split()[0], line.split()[1], line.split()[2], line.split()[3], line.split()[4])
except: except:
pass text = "Something wrong"
elif (type == "network"): elif (type == "network"):
try: try:
output = commands.getoutput("ifconfig -a -s").split("\n")[1:] output = commands.getoutput("ifconfig -a -s").split("\n")[1:]
@ -126,12 +127,12 @@ class PTMNotify:
output = commands.getoutput("wget http://checkip.dyndns.org/ -q -O - | awk '{print $6}' | sed 's/<.*>//g'") output = commands.getoutput("wget http://checkip.dyndns.org/ -q -O - | awk '{print $6}' | sed 's/<.*>//g'")
text = text + "External IP: %s" %(output[:-1]) text = text + "External IP: %s" %(output[:-1])
except: except:
pass text = "Something wrong"
elif (type == "battery"): elif (type == "battery"):
try: try:
text = text + "%s" %(commands.getoutput("acpi -abi")) text = text + "%s" %(commands.getoutput("acpi -abi"))
except: except:
pass text = "Something wrong"
content = [type, text] content = [type, text]
return content return content

View File

@ -49,6 +49,7 @@ class Reinit():
else: else:
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))') exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))')
# labels
for order in self.parent.label_order: for order in self.parent.label_order:
if (order == "1"): if (order == "1"):
if (self.parent.cpuBool > 0): if (self.parent.cpuBool > 0):
@ -101,7 +102,7 @@ class Reinit():
self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]')) self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]'))
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat): if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
self.parent.memInMb = True self.parent.memInMb = True
text = self.parent.formatLine.split('$LINE')[0] + self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[1] + self.parent.formatLine.split('$LINE')[1] line = self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[1]
elif (self.parent.memFormat.split('$mem')[0] != self.parent.memFormat): elif (self.parent.memFormat.split('$mem')[0] != self.parent.memFormat):
self.parent.memInMb = False self.parent.memInMb = False
self.parent.mem_used = 0.0 self.parent.mem_used = 0.0
@ -119,7 +120,7 @@ class Reinit():
self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]')) self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]'))
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat): if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
self.parent.swapInMb = True self.parent.swapInMb = True
text = self.parent.formatLine.split('$LINE')[0] + self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[1] + self.parent.formatLine.split('$LINE')[1] line = self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[1]
elif (self.parent.swapFormat.split('$swap')[0] != self.parent.swapFormat): elif (self.parent.swapFormat.split('$swap')[0] != self.parent.swapFormat):
self.parent.swapInMb = False self.parent.swapInMb = False
self.parent.swap_free = 1.0 self.parent.swap_free = 1.0
@ -281,7 +282,7 @@ class Reinit():
self.parent.theme = Plasma.Svg(self.parent) self.parent.theme = Plasma.Svg(self.parent)
self.parent.theme.setImagePath("widgets/background") self.parent.theme.setImagePath("widgets/background")
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground) self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.parent.resize(10,10) self.parent.resize(10, 10)
# create dataengines # create dataengines
self.parent.thread().wait(60000) self.parent.thread().wait(60000)

View File

@ -65,6 +65,9 @@
<property name="toolTip"> <property name="toolTip">
<string notr="true">$uptime - uptime</string> <string notr="true">$uptime - uptime</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -118,6 +121,9 @@
<string notr="true">$cpu - total load CPU, % <string notr="true">$cpu - total load CPU, %
$ccpu - load CPU for each core, %</string> $ccpu - load CPU for each core, %</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -174,6 +180,9 @@ $ccpu - load CPU for each core, %</string>
<string notr="true">$cpucl - average CPU clock, MHz <string notr="true">$cpucl - average CPU clock, MHz
$ccpucl - CPU clock for each core, MHz</string> $ccpucl - CPU clock for each core, MHz</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -242,6 +251,9 @@ $ccpucl - CPU clock for each core, MHz</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">$temp - physical temperature on CPU</string> <string notr="true">$temp - physical temperature on CPU</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -297,6 +309,9 @@ $ccpucl - CPU clock for each core, MHz</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">$gpu - gpu usage, %</string> <string notr="true">$gpu - gpu usage, %</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -352,6 +367,9 @@ $ccpucl - CPU clock for each core, MHz</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">$gputemp - physical temperature on GPU</string> <string notr="true">$gputemp - physical temperature on GPU</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -408,6 +426,9 @@ $ccpucl - CPU clock for each core, MHz</string>
<string notr="true">$mem - RAM usage, % <string notr="true">$mem - RAM usage, %
$memmb - RAM usage, MB</string> $memmb - RAM usage, MB</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -464,6 +485,9 @@ $memmb - RAM usage, MB</string>
<string notr="true">$swap - swap usage, % <string notr="true">$swap - swap usage, %
$swapmb - swap usage, MB</string> $swapmb - swap usage, MB</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -519,6 +543,9 @@ $swapmb - swap usage, MB</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">@@/;@@ - mount point usage, %</string> <string notr="true">@@/;@@ - mount point usage, %</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -574,6 +601,9 @@ $swapmb - swap usage, MB</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">@@/dev/sda@@ - physical temperature on /dev/sda</string> <string notr="true">@@/dev/sda@@ - physical temperature on /dev/sda</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -631,6 +661,9 @@ $swapmb - swap usage, MB</string>
$netdev - current network device $netdev - current network device
@@eth0@@ - disable auto select device and set specified device</string> @@eth0@@ - disable auto select device and set specified device</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -687,6 +720,9 @@ $netdev - current network device
<string notr="true">$bat - battery charge, % <string notr="true">$bat - battery charge, %
$ac - AC status</string> $ac - AC status</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -755,6 +791,9 @@ $ac - AC status</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">&quot;/sys/class/power_supply/BAT0/capacity&quot; by default</string> <string notr="true">&quot;/sys/class/power_supply/BAT0/capacity&quot; by default</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -795,6 +834,9 @@ $ac - AC status</string>
<property name="toolTip"> <property name="toolTip">
<string notr="true">&quot;/sys/class/power_supply/AC/online&quot; by default</string> <string notr="true">&quot;/sys/class/power_supply/AC/online&quot; by default</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -12,7 +12,7 @@ X-Plasma-RequiredExtensions=LaunchApp,LocalIO,FileDialog
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=py-text-monitor X-KDE-PluginInfo-Name=py-text-monitor
X-KDE-PluginInfo-Version=2.0.0 X-KDE-PluginInfo-Version=1.4.0
X-KDE-PluginInfo-Website=http://kde-look.org/ X-KDE-PluginInfo-Website=http://kde-look.org/
X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=