Compare commits

...

36 Commits

Author SHA1 Message Date
ebb828dd4c Edited readme 2013-11-06 04:48:28 +04:00
f5fa6af1bc Release 1.5.1
+ added date andtime support
2013-11-06 04:45:58 +04:00
ddf1de6f8e Yes another edit readme 2013-11-06 01:54:35 +04:00
4689a9054d Edited README 2013-11-06 01:39:33 +04:00
4a841766e8 Release 1.5.0
+ added music player support
+ added copyright
* edited README
2013-11-06 01:33:21 +04:00
7d5803fec8 Release ext-sysmon-1.3
+ added music players support: amarok, mpd and qmmp
2013-11-05 23:01:34 +04:00
60f1cd8c58 Fixed bug with notifyrc 2013-10-22 16:53:49 +04:00
b7f4b80c7e - 2013-10-22 16:25:05 +04:00
6c9a167aa2 Release 1.4.0
+ added notification
* small refactoring
2013-10-22 16:22:39 +04:00
d55d478243 Added network, hdd/hddtemp and battery notification 2013-10-08 21:56:08 +04:00
1dd3d4090c Added notification for gpu/gputemp 2013-10-08 14:25:52 +04:00
d5a91f566e Added notification for cpu/cpuclock/temp
+ notification carcass
2013-10-08 00:49:55 +04:00
3994652562 Added notification for uptime 2013-10-04 02:07:05 +04:00
c729d6573d Added todo (wish) list 2013-10-03 03:56:01 +04:00
7aabdf9485 Edited configuration interface
* changed (bool == 1) to (bool > 0)
2013-10-03 00:18:29 +04:00
d8a9ca1fe6 Started move to release 2.0.0
* recreated configuration interface
2013-10-02 19:54:42 +04:00
ff874f0b5e fixed pkgbuild 2013-09-30 01:14:17 +04:00
c3d953b99e Fixed #2
(it is true now =))
2013-09-29 06:18:44 +04:00
e7babdfde4 Release 1.3.6
* fix bug #1
* fix bug #2
2013-09-29 05:57:06 +04:00
013cf8d335 Fix optdep 2013-09-29 00:54:22 +04:00
3db0f5f126 Fix md5sum for ext-sysmon 2013-09-29 00:49:19 +04:00
c198b7596a Release 1.3.5
* fix bug with definition net dev in  old version of net-tools
2013-09-29 00:44:03 +04:00
1f18e2fe67 Fixed bug in install 2013-09-04 03:44:12 +04:00
1b3280c464 Small fixes in dataengine 2013-09-04 03:41:18 +04:00
2a686f4f1e Removed branches 2013-09-04 02:58:40 +04:00
4f7cb6aa3c Remove set locale from dataengine 2013-09-01 16:30:17 +04:00
1323d6d647 Bug fixes in ext-sysmon 2013-09-01 05:32:09 +04:00
2a2559d507 Fixed bug in pkgbuild 2013-08-29 18:45:38 +04:00
c8d7af4026 Added hddtemp to optdep 2013-08-27 13:34:11 +04:00
034c9eff7a Added automoc4 to makedep 2013-08-27 13:29:18 +04:00
cda78dbf1d Added cmake to makedep 2013-08-26 04:43:48 +04:00
8007c81129 Edited PKGBUILD 2013-08-26 04:39:16 +04:00
10511a8715 Fixed locale 2013-08-26 04:38:01 +04:00
9f77e83685 Edited PKGBUILD 2013-08-26 04:34:14 +04:00
17efef871a Release ext-sysmon-1.1
port from python to cpp
2013-08-26 04:30:46 +04:00
669571e803 Start rebuild dataengine from Python to CPP 2013-08-26 03:52:43 +04:00
32 changed files with 2602 additions and 2573 deletions

59
PKGBUILD Normal file
View File

@ -0,0 +1,59 @@
# Author: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
pkgname=kdeplasma-applets-pytextmonitor
_pkgname=py-text-monitor
pkgver=1.5.1
pkgrel=1
_dtengine=ext-sysmon
_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' 'sysstat')
optdepends=("hddtemp: for HDD temperature monitor"
"catalyst: 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=('3ef9536493e48cd460ee3f37faa8cf58'
'f7fce53d5f616891b30beac1afd99728')
build ()
{
# build dataengine
if [[ -d ${srcdir}/${_dtengine}/build ]]; then
rm -rf "${srcdir}/${_dtengine}/build"
fi
mkdir "${srcdir}/${_dtengine}/build"; cd "${srcdir}/${_dtengine}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` \
../
make
}
package()
{
# install dataengine
cd "${srcdir}/${_dtengine}/build"
make DESTDIR="${pkgdir}" install
# 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" \
"${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop"
install -D -m644 "${srcdir}/metadata.desktop" \
"${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/metadata.desktop"
mkdir -p "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/"{code,ui}
install -m644 "${srcdir}/contents/code/"* \
-t "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/code"
install -m644 "${srcdir}/contents/ui/"* \
-t "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/ui"
}

36
README
View File

@ -1,36 +0,0 @@
pytextmonitor
=============
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)

98
README.md Normal file
View File

@ -0,0 +1,98 @@
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 `$time` - time in long format. For example, `fri Nov 6 04:48:01 2013`
* label `$uptime` - uptime, <i>---d--h--m</i>
* label `$cpu` - total load cpu, <i>%</i>
* label `$ccpu` - load CPU for each core, <i>%</i>
* label `$cpucl` - average cpu clock, <i>MHz</i>
* label `$ccpucl` - cpu clock for each core, <i>MHz</i>
* label `$temp` - average temperature in system
* label `$gpu` - GPU usage, <i>%</i>. `aticonfig` or `nvidia-smi` must be installed
* label `$gputemp` - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
* label `$mem` - usage memory, <i>%</i>
* label `$memmb` - usage memory, <i>MB</i>
* label `$swap` - swap, <i>%</i>
* label `$swapmb` - swap, <i>MB</i>
* label `@@/@@` (in hdd label) - mount point (`/` in example) usage, <i>%</i>. Separator for mount points list is `;`, for example `@@/;/home;/mnt/global@@`
* label `@@/dev/sda@@` (in hddtemp label) - HDD (`/dev/sda` in example) temperature. `hddtemp` must be installed
* label `$net` - download and upload speed, <i>KB/s</i>. You may specify network device: something like `@@eth0@@`
* label `$netdev` - current network device
* label `$bat` - battery charge, <i>%</i>. 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 <i>(*)</i> if AC device is online or <i>( )</i> 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. <b>$cpu will work only in cpu label</b>.
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

30
create_archive.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# build dataengine
ARCHIVE="ext-sysmon"
VERSION=`grep Version ext-sysmon/plasma-engine-extsysmon.desktop | awk -F "=" '{print $2}'`
# create archive
if [ -e ${ARCHIVE}-${VERSION}.zip ]; then
rm -f ${ARCHIVE}-${VERSION}.zip
fi
zip -9 -y -r -q ${ARCHIVE}-${VERSION}.zip ${ARCHIVE}
# update md5sum
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.zip | awk '{print $1}'`
sed -i "/ '[0-9A-Fa-f]*/s/[^'][^)]*/ '${MD5SUMS}'/" PKGBUILD
sed -i "s/_dtver=[0-9.]*/_dtver=${VERSION}/" PKGBUILD
# build widget
cd sources
FILES="contents metadata.desktop plasma_applet_pytextmonitor"
ARCHIVE="py-text-monitor"
VERSION=`grep Version metadata.desktop | awk -F "=" '{print $2}'`
# create archive
if [ -e ${ARCHIVE}-${VERSION}.plasmoid ]; then
rm -f ${ARCHIVE}-${VERSION}.plasmoid
fi
zip -9 -y -r -q ../${ARCHIVE}-${VERSION}.plasmoid ${FILES}
cd ..
# update md5sum
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.plasmoid | awk '{print $1}'`
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD

BIN
ext-sysmon-1.3.zip Normal file

Binary file not shown.

24
ext-sysmon/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
# set project name
project (plasma_engine_extsysmon)
# find required libaries
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS}
${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES})
set (PLUGIN_NAME ${PROJECT_NAME})
file (GLOB PROJECT_DESKTOP *.desktop)
file (GLOB PROJECT_SRCS *.cpp)
# make
kde4_add_plugin (${PLUGIN_NAME} ${PROJECT_SRCS})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
# install
install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES ${PROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -1,95 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from PyKDE4 import plasmascript
import commands
class ExtendedSysMon(plasmascript.DataEngine):
def __init__(self, parent, args=None):
"""dataengine definition"""
plasmascript.DataEngine.__init__(self, parent)
def init(self):
"""initialization"""
self.setMinimumPollingInterval(333)
# setup gpu device
self.gpudev = ''
commandOut = commands.getoutput("lspci")
if (commandOut.lower().find('nvidia') > -1):
self.gpudev = 'nvidia'
elif (commandOut.lower().find('radeon') > -1):
self.gpudev = 'ati'
# setup hdd devices
self.hdddev = []
commandOut = commands.getoutput("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z]")
for device in commandOut.split('\n'):
if (device[:3] != "ls:"):
self.hdddev.append(device)
def sources(self):
"""create sources"""
sources = ["gpu", "gputemp", "hddtemp"]
return sources
def sourceRequestEvent(self, name):
return self.updateSourceEvent(name)
def updateSourceEvent(self, source):
"""update sources and setup values"""
if (source == "gpu"):
key = "GPU"
if (self.gpudev == 'nvidia'):
commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
try:
value = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1)))
except:
value = " N\A"
elif (self.gpudev == 'ati'):
commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
try:
value = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1)))
except:
value = " N\A"
else:
value = " N\A"
self.setData(source, "GPU", QString(value))
elif (source == "gputemp"):
if (self.gpudev == 'nvidia'):
commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
try:
value = "%4s" % (str(round(float(commandOut.split()[2]), 1)))
except:
value = " N\A"
elif (self.gpudev == 'ati'):
commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
try:
value = "%4s" % (str(round(float(commandOut.split()[4]), 1)))
except:
value = " N\A"
else:
value = " N\A"
self.setData(source, "GPUTemp", QString(value))
elif (source == "hddtemp"):
for device in self.hdddev:
commandOut = commands.getoutput("hddtemp " + device)
try:
value = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1)))
except:
value = " N\A"
self.setData(source, device, QString(value))
return True
def CreateDataEngine(parent):
return ExtendedSysMon(parent)

261
ext-sysmon/extsysmon.cpp Normal file
View File

@ -0,0 +1,261 @@
/***************************************************************************
* Copyright (C) 2013 by Evgeniy Alekseev <esalekseev@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 . *
***************************************************************************/
#include "extsysmon.h"
#include <Plasma/DataContainer>
#include <stdio.h>
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args)
{
Q_UNUSED(args)
setMinimumPollingInterval(333);
FILE *f_out;
f_out = popen("lspci 2>&1", "r");
char device[256];
QString dev;
while (fgets(device, 256, f_out) != NULL)
{
dev = QString(device);
if (dev.toLower().contains("nvidia"))
gpudev = QString("nvidia");
else if (dev.toLower().contains("radeon"))
gpudev = QString("ati");
}
pclose(f_out);
f_out = popen("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z] 2>&1", "r");
while (fgets(device, 256, f_out) != NULL)
{
dev = QString(device);
if (dev[0] == '/')
hdddev.append(dev);
}
pclose(f_out);
}
QStringList ExtendedSysMon::sources() const
{
QStringList source;
source.append(QString("gpu"));
source.append(QString("gputemp"));
source.append(QString("hddtemp"));
source.append(QString("player"));
return source;
}
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
{
return updateSourceEvent(name);
}
bool ExtendedSysMon::updateSourceEvent(const QString &source)
{
FILE *f_out;
QString key, out, tmp_out, value;
bool ok = false;
char output[256], val[5];
if (source == QString("gpu"))
{
key = QString("GPU");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d UTILIZATION 2> /dev/null | grep Gpu | tail -n1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 2))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2];
sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else if (gpudev == QString("ati"))
{
f_out = popen("aticonfig --od-getclocks 2> /dev/null | grep load | tail -n1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 3))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[3];
sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else
{
value = QString(" N\\A");
}
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("gputemp"))
{
key = QString("GPUTemp");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d TEMPERATURE 2> /dev/null | grep Gpu | tail -n1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 2))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2];
sprintf (val, "%4.1f", out.toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else if (gpudev == QString("ati"))
{
f_out = popen("aticonfig --od-gettemperature 2> /dev/null | grep Temperature | tail -n1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 4))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[4];
sprintf (val, "%4.1f", out.toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else
{
value = QString(" N\\A");
}
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("hddtemp"))
{
char command[256], *dev;
QByteArray qb;
for (int i=0; i<hdddev.count(); i++)
{
qb = hdddev[i].toUtf8();
dev = qb.data();
sprintf(command, "hddtemp %s 2> /dev/null", dev);
f_out = popen(command, "r");
fgets(output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(":"), QString::SkipEmptyParts).count() < 3))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(":"), QString::SkipEmptyParts)[2];
sprintf (val, "%4.1f", out.left(out.count()-4).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, hdddev[i], value);
}
}
else if (source == QString("player"))
{
// qmmp
output[0] = '\0';
key = QString("qmmp_artist");
f_out = popen("qmmp --nowplaying '%if(%p,%p,Unknown)' 2> /dev/null", "r");
fgets(output, 256, f_out);
if (output[0] == '\0')
value = QString("N\\A");
else
value = QString(output).split(QString("\n"), QString::SkipEmptyParts)[0];
pclose(f_out);
setData(source, key, value);
output[0] = '\0';
key = QString("qmmp_title");
f_out = popen("qmmp --nowplaying '%if(%t,%t,Unknown)' 2> /dev/null", "r");
fgets(output, 256, f_out);
if (output[0] == '\0')
value = QString("N\\A");
else
value = QString(output).split(QString("\n"), QString::SkipEmptyParts)[0];
pclose(f_out);
setData(source, key, value);
// amarok
output[0] = '\0';
key = QString("amarok_artist");
f_out = popen("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-", "r");
fgets(output, 256, f_out);
if (output[0] == '\0')
value = QString("N\\A");
else
value = QString(output).split(QString("\n"), QString::SkipEmptyParts)[0];
pclose(f_out);
setData(source, key, value);
output[0] = '\0';
key = QString("amarok_title");
f_out = popen("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep title: | cut -c8-", "r");
fgets(output, 256, f_out);
if (output[0] == '\0')
value = QString("N\\A");
else
value = QString(output).split(QString("\n"), QString::SkipEmptyParts)[0];
pclose(f_out);
setData(source, key, value);
// mpd
QString value_artist;
value = QString("N\\A");
value_artist = QString("N\\A");
f_out = popen("echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://localhost:6600 2> /dev/null", "r");
while (true)
{
fgets(output, 256, f_out);
if (feof (f_out))
break;
if (QString(output).split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
value_artist = QString(output).split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (QString(output).split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
value = QString(output).split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
pclose(f_out);
key = QString("mpd_artist");
setData(source, key, value_artist);
key = QString("mpd_title");
setData(source, key, value);
}
return true;
}
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
#include "extsysmon.moc"

40
ext-sysmon/extsysmon.h Normal file
View File

@ -0,0 +1,40 @@
/***************************************************************************
* Copyright (C) 2013 by Evgeniy Alekseev <esalekseev@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 . *
***************************************************************************/
#ifndef EXTSYSMON_H
#define EXTSYSMON_H
#include <Plasma/DataEngine>
class ExtendedSysMon : public Plasma::DataEngine
{
Q_OBJECT
public:
ExtendedSysMon(QObject *parent, const QVariantList &args);
protected:
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList hdddev;
QString gpudev;
QStringList sources() const;
};
#endif // EXTSYSMON_H

View File

@ -6,14 +6,14 @@ ServiceTypes=Plasma/DataEngine
Type=Service
Icon=utilities-system-monitor
X-Plasma-API=python
X-Plasma-MainScript=code/main.py
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_extsysmon
X-Plasma-EngineName=ext-sysmon
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=ext-sysmon
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://kde-look.org/
X-KDE-PluginInfo-Version=1.3
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
from util import *
class Config():
def __init__(self, applet):
self.applet = applet
self.config = self.applet.config()
def get(self, key, default = ''):
return self.config.readEntry(key, default).toString()
def set(self, key, value):
self.config.writeEntry(key, value)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
# -*- 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 *
class Config():
def __init__(self, applet):
self.applet = applet
self.config = self.applet.config()
def get(self, key, default = ''):
return self.config.readEntry(key, default).toString()
def set(self, key, value):
self.config.writeEntry(key, 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.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
@ -37,15 +53,15 @@ class ConfigDefinition:
settings.set('font_weight', self.parent.font_weight)
# disconnecting from source and clear layout
if (self.parent.uptimeBool == 1):
if (self.parent.uptimeBool > 0):
self.parent.systemmonitor.disconnectSource("system/uptime", self.parent)
self.parent.label_uptime.setText('')
self.parent.layout.removeItem(self.parent.label_uptime)
if (self.parent.cpuBool == 1):
if (self.parent.cpuBool > 0):
self.parent.systemmonitor.disconnectSource("cpu/system/TotalLoad", self.parent)
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
self.parent.label_cpu0.setText('')
self.parent.layout.removeItem(self.parent.label_cpu0)
self.parent.label_cpu.setText('')
self.parent.layout.removeItem(self.parent.label_cpu)
self.parent.label_cpu1.setText('')
self.parent.layout.removeItem(self.parent.label_cpu1)
for core in range(self.parent.numCores):
@ -55,11 +71,11 @@ class ConfigDefinition:
else:
self.parent.label_cpu.setText('')
self.parent.layout.removeItem(self.parent.label_cpu)
if (self.parent.cpuclockBool == 1):
if (self.parent.cpuclockBool > 0):
self.parent.systemmonitor.disconnectSource("cpu/system/AverageClock", self.parent)
if (self.parent.cpuclockFormat.split('$ccpu')[0] != self.parent.cpuclockFormat):
self.parent.label_cpuclock0.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock0)
self.parent.label_cpuclock.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock)
self.parent.label_cpuclock1.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock1)
for core in range(self.parent.numCores):
@ -69,32 +85,32 @@ class ConfigDefinition:
else:
self.parent.label_cpuclock.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock)
if (self.parent.tempBool == 1):
if (self.parent.tempBool > 0):
self.parent.systemmonitor.disconnectSource(self.parent.tempdev, self.parent)
self.parent.label_temp.setText('')
self.parent.layout.removeItem(self.parent.label_temp)
if (self.parent.gpuBool == 1):
if (self.parent.gpuBool > 0):
self.parent.extsysmon.disconnectSource("gpu", self.parent)
self.parent.label_gpu.setText('')
self.parent.layout.removeItem(self.parent.label_gpu)
if (self.parent.gputempBool == 1):
if (self.parent.gputempBool > 0):
self.parent.extsysmon.disconnectSource("gputemp", self.parent)
self.parent.label_gputemp.setText('')
self.parent.layout.removeItem(self.parent.label_gputemp)
if (self.parent.memBool == 1):
if (self.parent.memBool > 0):
self.parent.systemmonitor.disconnectSource("mem/physical/application", self.parent)
if (self.parent.memInMb == False):
self.parent.systemmonitor.disconnectSource("mem/physical/free", self.parent)
self.parent.systemmonitor.disconnectSource("mem/physical/used", self.parent)
self.parent.label_mem.setText('')
self.parent.layout.removeItem(self.parent.label_mem)
if (self.parent.swapBool == 1):
if (self.parent.swapBool > 0):
self.parent.systemmonitor.disconnectSource("mem/swap/used", self.parent)
if (self.parent.swapInMb == False):
self.parent.systemmonitor.disconnectSource("mem/swap/free", self.parent)
self.parent.label_swap.setText('')
self.parent.layout.removeItem(self.parent.label_swap)
if (self.parent.hddBool == 1):
if (self.parent.hddBool > 0):
for mount in self.parent.mountPoints:
self.parent.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self.parent)
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText("")')
@ -103,30 +119,36 @@ class ConfigDefinition:
self.parent.label_hdd1.setText('')
self.parent.layout.removeItem(self.parent.label_hdd0)
self.parent.layout.removeItem(self.parent.label_hdd1)
if (self.parent.hddtempBool == 1):
if (self.parent.hddtempBool > 0):
self.parent.extsysmon.disconnectSource("hddtemp", self.parent)
self.parent.label_hddtemp.setText('')
self.parent.layout.removeItem(self.parent.label_hddtemp)
if (self.parent.netBool == 1):
if (self.parent.netBool > 0):
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
self.parent.label_netDown.setText('')
self.parent.label_netUp.setText('')
self.parent.layout.removeItem(self.parent.label_netUp)
self.parent.layout.removeItem(self.parent.label_netDown)
if (self.parent.batBool == 1):
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.extsysmon.disconnectSource("player", self.parent)
self.parent.label_player.setText('')
self.parent.layout.removeItem(self.parent.label_player)
if (self.parent.timeBool > 0):
self.parent.timemon.disconnectSource("Local", self.parent)
self.parent.label_time.setText('')
self.parent.layout.removeItem(self.parent.label_time)
self.parent.label_order = "------------"
self.parent.label_order = "--------------"
for label in self.parent.dict_orders.keys():
if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() == 2):
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 1')
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = ' + str(self.configpage.checkboxes[self.parent.dict_orders[label]].checkState()))
if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() > 0):
pos = self.configpage.sliders[self.parent.dict_orders[label]].value() - 1
self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:]
else:
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = 0')
if (self.parent.dict_orders[label] == 'net'):
exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
exec ('settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
@ -142,12 +164,15 @@ 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)
# reinitializate
self.parent.reinit.reinit()
self.parent.reinit.reinit(confAccept=True)
def createConfigurationInterface(self, parent):
@ -167,11 +192,9 @@ class ConfigDefinition:
self.configpage.ui.spinBox_weight.setValue(settings.get('font_weight', 400).toInt()[0])
for label in self.parent.dict_orders.keys():
exec ('bool = self.parent.' + self.parent.dict_orders[label] + 'Bool')
if (bool == 1):
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(2)
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(bool)
if (bool > 0):
self.configpage.sliders[self.parent.dict_orders[label]].setValue(self.parent.label_order.find(label)+1)
else:
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(0)
if (self.parent.dict_orders[label] == 'net'):
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
else:
@ -190,6 +213,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, 'time':self.ui.checkBox_time}
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, 'time':self.ui.slider_time}
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, 'time':self.ui.lineEdit_time}
for item in self.checkboxes.values():
QObject.connect(item, SIGNAL("stateChanged(int)"), self.setStatus)
@ -43,7 +62,7 @@ class ConfigWindow(QWidget):
"""function to enable label"""
count = self.sliders['bat'].maximum()
for label in self.checkboxes.keys():
if ((self.checkboxes[label].checkState() == 2) and (self.sliders[label].isEnabled() == False)):
if ((self.checkboxes[label].checkState() > 0) and (self.sliders[label].isEnabled() == False)):
self.lineedits[label].setEnabled(True)
self.sliders[label].setEnabled(True)
if (label == 'bat'):
@ -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,49 +32,55 @@ class DataEngine:
def connectToEngine(self):
"""function to initializate engine"""
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
if ((self.parent.gputempBool == 1) or (self.parent.gpuBool == 1) or (self.parent.hddtempBool == 1)):
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 == 1):
if (self.parent.timeBool > 0):
self.parent.timemon = self.parent.dataEngine("time")
self.parent.timemon.connectSource("Local", self.parent, 1000)
if (self.parent.uptimeBool > 0):
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
if (self.parent.cpuBool == 1):
if (self.parent.cpuBool > 0):
self.parent.systemmonitor.connectSource("cpu/system/TotalLoad", self.parent, self.parent.interval)
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
for core in range(self.parent.numCores):
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent, self.parent.interval)
if (self.parent.cpuclockBool == 1):
if (self.parent.cpuclockBool > 0):
self.parent.systemmonitor.connectSource("cpu/system/AverageClock", self.parent, self.parent.interval)
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
for core in range(self.parent.numCores):
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval)
if (self.parent.tempBool == 1):
if (self.parent.tempBool > 0):
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
if (self.parent.gpuBool == 1):
if (self.parent.gpuBool > 0):
self.parent.extsysmon.connectSource("gpu", self.parent, self.parent.interval)
if (self.parent.gputempBool == 1):
if (self.parent.gputempBool > 0):
self.parent.extsysmon.connectSource("gputemp", self.parent, self.parent.interval)
if (self.parent.memBool == 1):
if (self.parent.memBool > 0):
if (self.parent.memInMb):
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval)
else:
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, int(self.parent.interval*0.5))
if (self.parent.swapBool == 1):
if (self.parent.swapBool > 0):
if (self.parent.swapInMb):
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval)
else:
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, int(self.parent.interval*0.5))
if (self.parent.hddBool == 1):
if (self.parent.hddBool > 0):
for mount in self.parent.mountPoints:
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
if (self.parent.hddtempBool == 1):
if (self.parent.hddtempBool > 0):
self.parent.extsysmon.connectSource("hddtemp", self.parent, self.parent.interval)
if (self.parent.netBool == 1):
if (self.parent.netBool > 0):
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"""
@ -81,7 +103,7 @@ class DataEngine:
else:
line = self.parent.cpuFormat.split('$ccpu')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu0.setText(text)
self.parent.label_cpu.setText(text)
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
else:
@ -109,7 +131,7 @@ class DataEngine:
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock0.setText(text)
self.parent.label_cpuclock.setText(text)
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
else:
@ -153,7 +175,7 @@ class DataEngine:
if (self.parent.netNonFormat.split('@@')[0] == self.parent.netNonFormat):
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
self.parent.setupNetdev()
self.parent.netdev = self.parent.setupNetdev()
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.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
@ -231,7 +253,36 @@ 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)
elif (sourceName == "Local"):
value = str(data[QString(u'DateTime')].toString().toUtf8())
if (self.parent.timeFormat.split('$time')[0] != self.parent.timeFormat):
line = self.parent.timeFormat.split('$time')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$time')[1]
else:
line = self.parent.timeFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_time.setText(text)
self.parent.update()
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.kdecore import *
@ -7,7 +23,7 @@ from PyKDE4.kdeui import *
from PyKDE4.kio import *
from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma
import commands, os, time
import commands, os, shutil, time
import configdef
import configwindow
@ -21,8 +37,8 @@ class pyTextWidget(plasmascript.Applet):
def __init__(self, parent, args=None):
"""widget definition"""
plasmascript.Applet.__init__(self, parent)
def init(self):
"""function to initializate widget"""
self._name = str(self.package().metadata().pluginName())
@ -36,9 +52,14 @@ class pyTextWidget(plasmascript.Applet):
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
self.setupVar()
self.reinit.reinit()
self.reinit.reinit(confAccept=False)
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")) and
(not os.path.exists("/usr" + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"))):
self.createNotifyrc(kdehome)
def createConfigurationInterface(self, parent):
@ -48,6 +69,14 @@ class pyTextWidget(plasmascript.Applet):
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):
"""function to create tooltip"""
self.tooltip = Plasma.ToolTipContent()
@ -57,29 +86,30 @@ class pyTextWidget(plasmascript.Applet):
# show tooltip
#Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
def mouseDoubleClickEvent(self, event):
"""function to doubleclick event"""
os.system("ksysguard")
os.system("ksysguard &")
def setupNetdev(self):
"""function to setup network device"""
self.netdev = "lo"
netdev = "lo"
try:
interfaces = []
for line in commands.getoutput("ifconfig -a").split("\n"):
if ((line != '') and (line[0] != ' ') and (line[0:3] != 'lo:')):
interfaces.append(line.split(":")[0])
for line in commands.getoutput("ifconfig -a -s").split("\n"):
if ((line.split()[0] != 'Iface') and (line.split()[0] != 'lo')):
interfaces.append(line.split()[0])
for device in interfaces:
if (commands.getoutput("ifconfig " + device + " | grep 'inet '") != ''):
self.netdev = device
netdev = device
break
except:
pass
return netdev
def setupVar(self):
"""function to setup variables"""
self.netdev = ''
@ -89,19 +119,21 @@ 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', 'e':'time'}
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]', 'time':'[$time]'}
def showConfigurationInterface(self):
"""function to show configuration window"""
plasmascript.Applet.showConfigurationInterface(self)
def startPolling(self):
try:
self.timer.start()
@ -113,17 +145,17 @@ class pyTextWidget(plasmascript.Applet):
self.label_error.setText('<font color="red">ERROR</font>')
self.layout.addItem(self.label_error)
return
def updateLabel(self):
"""function to update label"""
if ((self.memBool == 1) and (self.memInMb == False)):
if ((self.memBool > 0) and (self.memInMb == False)):
self.memText()
if ((self.swapBool == 1) and (self.swapInMb == False)):
if ((self.swapBool > 0) and (self.swapInMb == False)):
self.swapText()
if (self.batBool == 1):
if (self.batBool > 0):
self.batText()
def batText(self):
"""function to set battery text"""
line = self.batFormat
@ -149,8 +181,8 @@ class pyTextWidget(plasmascript.Applet):
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_bat.setText(text)
def memText(self):
"""function to set mem text"""
full = self.mem_uf + self.mem_free
@ -162,8 +194,8 @@ class pyTextWidget(plasmascript.Applet):
line = self.memFormat
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_mem.setText(text)
def swapText(self):
"""function to set swap text"""
full = self.swap_used + self.swap_free
@ -185,4 +217,4 @@ class pyTextWidget(plasmascript.Applet):
def CreateApplet(parent):
return pyTextWidget(parent)
return pyTextWidget(parent)

View File

@ -0,0 +1,49 @@
[Global]
IconName=system
Name=PyTextMonitor
Comment=PyTextMonitor information
[Event/system]
Name=System information
Comment=System information
Action=Popup
[Event/processor]
Name=Processor information
Comment=Processor information
Action=Popup
[Event/graphical]
Name=GPU information
Comment=GPU information
Action=Popup
[Event/memory]
Name=Memory information
Comment=Memory information
Action=Popup
[Event/disk]
Name=Disk information
Comment=Disk information
Action=Popup
[Event/network]
Name=Network information
Comment=Network information
Action=Popup
[Event/battery]
Name=Battery information
Comment=Battery information
Action=Popup
[Event/graphinfo]
Name=Graphical Information
Comment=Graphical Information
Action=Popup
[Event/musicplayer]
Name=Now playing
Comment=Now playing
Action=Popup

View File

@ -0,0 +1,266 @@
# -*- 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
class PTMNotify:
def __init__(self, parent):
"""class definition"""
self.parent = parent
def init(self):
"""function to init notification"""
content = self.initText(self.parent)
self.createNotify(content)
def createNotify(self, content):
"""function to create notification for label"""
notification = KNotification(content[0])
notification.setComponentData(KComponentData("plasma_applet_pytextmonitor"))
notification.setTitle("PyTextMonitor info ::: " + content[0]);
notification.setText(content[1]);
notification.sendEvent();
def createText(self, type):
"""function to create text"""
text = ""
if (type == "system"):
try:
text = text + "Kernel: %s\n" %(commands.getoutput("uname -rsm"))
text = text + "Hostname: %s\n" %(commands.getoutput("uname -n"))
text = text + "Whoami: %s\n" %(commands.getoutput("whoami"))
text = text + "Uptime: %s\n" %(commands.getoutput("uptime"))
except:
text = "Something wrong"
elif (type == "processor"):
try:
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
text = text + "Model: %s\n" %(' '.join(output.split()[3:]))
output = commands.getoutput("sar -u | tail -1")
text = text + "CPU Usage: %s%%\n" %(str(100-float(output.split()[-1])))
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
text = text + "CPU Freq: %s MHz\n" %(str(int(float(output.split()[-1]))))
output = commands.getoutput("sensors -u")
text = text + "Temps:"
for line in output.split("\n"):
if (line.find("_input") > -1):
text = text + " %s\xb0C" %(str(round(float(line.split()[-1]), 0)))
except:
text = "Something wrong"
elif (type == "graphical"):
try:
output = commands.getoutput("lspci -m | grep 'VGA\|3D'")
if (output.lower().find('nvidia') > -1):
gpudev = "nvidia"
elif (output.lower().find('radeon') > -1):
gpudev = "ati"
for line in output.split("\n"):
text = text + "%s %s\n" %(line.split('"')[0], line.split('"')[5])
if (gpudev == 'nvidia'):
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
except:
value = " N\A"
elif (gpudev == 'ati'):
output = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
except:
value = " N\A"
else:
value = " N\A"
text = text + "Load: %s%%\n" %(value)
if (gpudev == 'nvidia'):
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
except:
value = " N\A"
elif (gpudev == 'ati'):
output = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
except:
value = " N\A"
else:
value = " N\A"
text = text + "Temp: %s\xb0C\n" %(value)
except:
text = "Something wrong"
elif (type == "memory"):
try:
output = commands.getoutput("free -m -o").split("\n")
memusage = int(output[1].split()[1]) - (int(output[1].split()[3]) + int(output[1].split()[5]) + int(output[1].split()[6]))
text = text + "Memory: %s of %s (%s%%)\n" %(str(memusage), output[1].split()[1], str(int(100*memusage/int(output[1].split()[1]))))
text = text + "Swap: %s of %s (%s%%)\n" %(output[2].split()[2], output[2].split()[1], str(int(100*int(output[2].split()[2])/int(output[2].split()[1]))))
output = commands.getoutput("swapon --show").split("\n")
text = text + "Swap Device: %s (%s)" %(output[1].split()[0], output[1].split()[1])
except:
text = "Something wrong"
elif (type == "disk"):
try:
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:
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:
text = "Something wrong"
elif (type == "network"):
try:
output = commands.getoutput("ifconfig -a -s").split("\n")[1:]
text = text + "Devices:"
for line in output:
text = text + " %s" %(line.split()[0])
output = commands.getoutput("ifconfig -a -s " + self.parent.parent.netdev + " && sleep 0.2 && ifconfig -a -s " + self.parent.parent.netdev).split("\n")
download = int((int(output[3].split()[2]) - int(output[1].split()[2])) / (0.2 * 1024))
upload = int((int(output[3].split()[6]) - int(output[1].split()[6])) / (0.2 * 1024))
text = text + "\n%s: %s/%s KB/s\n" %(self.parent.parent.netdev, download, upload)
output = commands.getoutput("ifconfig " + self.parent.parent.netdev + " | grep 'inet '").split()[1]
text = text + "IP: %s\n" %(output[:-1])
output = commands.getoutput("wget http://checkip.dyndns.org/ -q -O - | awk '{print $6}' | sed 's/<.*>//g'")
text = text + "External IP: %s" %(output[:-1])
except:
text = "Something wrong"
elif (type == "battery"):
try:
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
def initText(self, sender):
"""function to send text"""
try:
if (sender == self.parent.parent.label_time):
content = self.createText("system")
return content
except:
pass
try:
if (sender == self.parent.parent.label_uptime):
content = self.createText("system")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpu):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpuclock):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_temp):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gpu):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gputemp):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_mem):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_swap):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hdd0):
content = self.createText("disk")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hddtemp):
content = self.createText("disk")
return content
except:
pass
try:
if (sender == self.parent.parent.label_netDown):
content = self.createText("network")
return content
except:
pass
try:
if (sender == self.parent.parent.label_bat):
content = self.createText("battery")
return content
except:
pass
try:
if (sender == self.parent.parent.label_player):
content = self.createText("musicplayer")
return content
except:
pass

View File

@ -1,8 +1,42 @@
# -*- 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
import config
import ptmnotify
class NewPlasmaLabel(Plasma.Label):
"""new Label with defined clicked() event"""
def __init__(self, applet, parent):
"""class definition"""
Plasma.Label.__init__(self, applet)
self.parent = parent
self.notify = ptmnotify.PTMNotify(self)
def mousePressEvent(self, event):
"""mouse click event"""
if (event.button() == Qt.LeftButton):
self.notify.init()
@ -10,8 +44,9 @@ class Reinit():
def __init__(self, parent):
"""class definition"""
self.parent = parent
def reinit(self):
def reinit(self, confAccept=False):
"""function to reinitializate widget"""
settings = config.Config(self.parent)
self.parent.interval = settings.get('interval', 2000).toInt()[0]
@ -26,37 +61,25 @@ class Reinit():
self.parent.label_order = str(settings.get('label_order', '1345'))
for label in self.parent.dict_orders.values():
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 1))')
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 2))')
else:
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))')
# small function for update if errors exist
summ = 0
for label in self.parent.dict_orders.values():
exec ('summ += self.parent.' + label + 'Bool')
if (len(self.parent.label_order) != summ):
for label in self.parent.dict_orders.values():
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
exec ('self.parent.' + label + 'Bool = 1')
else:
exec ('self.parent.' + label + 'Bool = 0')
exec ('settings.set("' + label + 'Bool", self.parent.' + label + 'Bool)')
self.parent.label_order = '1345'
settings.set('label_order', self.parent.label_order)
# labels
for order in self.parent.label_order:
if (order == "1"):
if (self.parent.cpuBool == 1):
if (self.parent.cpuBool > 0):
self.parent.cpuFormat = str(settings.get('cpuFormat', '[cpu: $cpu%]'))
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
self.parent.label_cpu0 = Plasma.Label(self.parent.applet)
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_cpu1 = Plasma.Label(self.parent.applet)
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
else:
line = self.parent.cpuFormat.split('$ccpu')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu0.setText(text)
self.parent.layout.addItem(self.parent.label_cpu0)
self.parent.label_cpu.setText(text)
self.parent.layout.addItem(self.parent.label_cpu)
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
for core in range(self.parent.numCores):
exec ('self.parent.label_coreCpu' + str(core) + ' = Plasma.Label(self.parent.applet)')
@ -70,7 +93,7 @@ class Reinit():
self.parent.label_cpu1.setText(text)
self.parent.layout.addItem(self.parent.label_cpu1)
else:
self.parent.label_cpu = Plasma.Label(self.parent.applet)
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
line = self.parent.cpuFormat.split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$cpu')[1]
else:
@ -79,10 +102,10 @@ class Reinit():
self.parent.label_cpu.setText(text)
self.parent.layout.addItem(self.parent.label_cpu)
elif (order == "2"):
if (self.parent.tempBool == 1):
if (self.parent.tempBool > 0):
self.parent.tempdev = str(settings.get('temp_device', '<select device>'))
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp&deg;C]'))
self.parent.label_temp = Plasma.Label(self.parent.applet)
self.parent.label_temp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
line = self.parent.tempFormat.split('$temp')[0] + '----' + self.parent.tempFormat.split('$temp')[1]
else:
@ -91,11 +114,11 @@ class Reinit():
self.parent.label_temp.setText(text)
self.parent.layout.addItem(self.parent.label_temp)
elif (order == "3"):
if (self.parent.memBool == 1):
if (self.parent.memBool > 0):
self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]'))
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
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):
self.parent.memInMb = False
self.parent.mem_used = 0.0
@ -105,15 +128,15 @@ class Reinit():
else:
line = self.parent.memFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_mem = Plasma.Label(self.parent.applet)
self.parent.label_mem = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_mem.setText(text)
self.parent.layout.addItem(self.parent.label_mem)
elif (order == "4"):
if (self.parent.swapBool == 1):
if (self.parent.swapBool > 0):
self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]'))
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
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):
self.parent.swapInMb = False
self.parent.swap_free = 1.0
@ -122,22 +145,22 @@ class Reinit():
else:
line = self.parent.swapFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_swap = Plasma.Label(self.parent.applet)
self.parent.label_swap = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_swap.setText(text)
self.parent.layout.addItem(self.parent.label_swap)
elif (order == "5"):
if (self.parent.netBool == 1):
if (self.parent.netBool > 0):
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]'))
if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat):
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
else:
self.parent.setupNetdev()
self.parent.netdev = self.parent.setupNetdev()
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
else:
self.parent.netFormat = self.parent.netNonFormat
self.parent.label_netDown = Plasma.Label(self.parent.applet)
self.parent.label_netDown = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
line = self.parent.netFormat.split('$net')[0] + '----'
else:
@ -154,11 +177,11 @@ class Reinit():
self.parent.label_netUp.setText(text)
self.parent.layout.addItem(self.parent.label_netUp)
elif (order == "6"):
if (self.parent.batBool == 1):
if (self.parent.batBool > 0):
self.parent.batFormat = str(settings.get('batFormat', '[bat: $bat%$ac]'))
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.label_bat = Plasma.Label(self.parent.applet)
self.parent.label_bat = NewPlasmaLabel(self.parent.applet, self.parent)
line = self.parent.batFormat
if (line.split('$ac')[0] != line):
line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1]
@ -168,18 +191,18 @@ class Reinit():
self.parent.label_bat.setText(text)
self.parent.layout.addItem(self.parent.label_bat)
elif (order == "7"):
if (self.parent.cpuclockBool == 1):
if (self.parent.cpuclockBool > 0):
self.parent.cpuclockFormat = str(settings.get('cpuclockFormat', '[mhz: $cpucl]'))
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
self.parent.label_cpuclock0 = Plasma.Label(self.parent.applet)
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_cpuclock1 = Plasma.Label(self.parent.applet)
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock0.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock0)
self.parent.label_cpuclock.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock)
text = self.parent.formatLine.split('$LINE')[0] + "----" + self.parent.formatLine.split('$LINE')[1]
for core in range(self.parent.numCores):
exec ('self.parent.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.parent.applet)')
@ -193,7 +216,7 @@ class Reinit():
self.parent.label_cpuclock1.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock1)
else:
self.parent.label_cpuclock = Plasma.Label(self.parent.applet)
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
line = self.parent.cpuclockFormat.split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$cpucl')[1]
else:
@ -202,9 +225,9 @@ class Reinit():
self.parent.label_cpuclock.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock)
elif (order == "8"):
if (self.parent.uptimeBool == 1):
if (self.parent.uptimeBool > 0):
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
self.parent.label_uptime = Plasma.Label(self.parent.applet)
self.parent.label_uptime = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1]
else:
@ -213,9 +236,9 @@ class Reinit():
self.parent.label_uptime.setText(text)
self.parent.layout.addItem(self.parent.label_uptime)
elif (order == "9"):
if (self.parent.gpuBool == 1):
if (self.parent.gpuBool > 0):
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
self.parent.label_gpu = Plasma.Label(self.parent.applet)
self.parent.label_gpu = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1]
else:
@ -224,9 +247,9 @@ class Reinit():
self.parent.label_gpu.setText(text)
self.parent.layout.addItem(self.parent.label_gpu)
elif (order == "a"):
if (self.parent.gputempBool == 1):
if (self.parent.gputempBool > 0):
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp&deg;C]'))
self.parent.label_gputemp = Plasma.Label(self.parent.applet)
self.parent.label_gputemp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1]
else:
@ -235,13 +258,13 @@ class Reinit():
self.parent.label_gputemp.setText(text)
self.parent.layout.addItem(self.parent.label_gputemp)
elif (order == "b"):
if (self.parent.hddBool == 1):
if (self.parent.hddBool > 0):
self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: @@/@@%]'))
if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
line = self.parent.hddFormat.split('@@')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hdd0 = Plasma.Label(self.parent.applet)
self.parent.label_hdd0 = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_hdd0.setText(text)
self.parent.layout.addItem(self.parent.label_hdd0)
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
@ -260,9 +283,9 @@ class Reinit():
self.parent.label_hdd0.setText(text)
self.parent.layout.addItem(self.parent.label_hdd0)
elif (order == "c"):
if (self.parent.hddtempBool == 1):
if (self.parent.hddtempBool > 0):
self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@&deg;C]'))
self.parent.label_hddtemp = Plasma.Label(self.parent.applet)
self.parent.label_hddtemp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
line = self.parent.hddtempFormat.split('@@')[0] + '----' + self.parent.hddtempFormat.split('@@')[2]
else:
@ -270,20 +293,41 @@ 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)
self.parent.applet.setLayout(self.parent.layout)
self.parent.theme = Plasma.Svg(self.parent)
self.parent.theme.setImagePath("widgets/background")
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.parent.resize(10,10)
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)
elif (order == "e"):
if (self.parent.timeBool > 0):
self.parent.timeFormat = str(settings.get('timeFormat', '[$time]'))
self.parent.label_time = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.timeFormat.split('$time')[0] != self.parent.timeFormat):
line = self.parent.timeFormat.split('$time')[0] + '----------------------' + self.parent.timeFormat.split('$time')[1]
else:
line = self.parent.timeFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_time.setText(text)
self.parent.layout.addItem(self.parent.label_time)
if not confAccept:
self.parent.applet.setLayout(self.parent.layout)
self.parent.theme = Plasma.Svg(self.parent)
self.parent.theme.setImagePath("widgets/background")
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.parent.resize(10, 10)
# create dataengines
label_start = True
while label_start:
try:
self.parent.dataengine.connectToEngine()
label_start = False
except:
pass
self.parent.thread().wait(60000)
self.parent.dataengine.connectToEngine()
self.parent.timer.setInterval(self.parent.interval)
self.parent.startPolling()

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

File diff suppressed because it is too large Load Diff

View File

@ -9,10 +9,10 @@ X-Plasma-API=python
X-Plasma-MainScript=code/main.py
X-Plasma-RequiredExtensions=LaunchApp,LocalIO,FileDialog
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
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.3.4
X-KDE-PluginInfo-Version=1.5.1
X-KDE-PluginInfo-Website=http://kde-look.org/
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=