Compare commits

...

19 Commits

Author SHA1 Message Date
1b5e2c7fea edited readme 2014-03-27 20:10:59 +04:00
a3a5ebf2af release 1.5.3 2014-03-27 20:09:46 +04:00
0d3aacdec7 Fixed zero swap and memory 2013-11-19 18:17:59 +04:00
5bcf76a136 Fixed pkgrel 2013-11-18 21:20:40 +04:00
29da9b43f3 Edited README 2013-11-18 21:09:03 +04:00
e2e511f083 Release pytextmonitor 1.5.2
+ added time formats
* fixed definition of conf file for dataengine
2013-11-18 21:02:55 +04:00
ccaca2a725 Edited for 1.5 ext-sysmon 2013-11-18 19:51:57 +04:00
916c32589f Release ext-sysmon 1.5
+ added configuration file
2013-11-18 19:16:38 +04:00
24325e2d3a Edited archives 2013-11-11 09:50:23 +04:00
9569400757 Edited for #6 2013-11-11 09:47:48 +04:00
4d4317150a Edited pkgbuild 2013-11-07 01:45:55 +04:00
946c0ea874 Release ext-sysmon 1.4
* fix #4
2013-11-07 01:38:32 +04:00
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
27 changed files with 888 additions and 160 deletions

View File

@ -3,40 +3,43 @@
pkgname=kdeplasma-applets-pytextmonitor
_pkgname=py-text-monitor
pkgver=1.4.0
pkgver=1.5.3
pkgrel=1
_dtengine=ext-sysmon
_dtver=1.2
_dtver=1.6
pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm"
arch=('i686' 'x86_64')
url="https://github.com/arcan1s/pytextmonitor"
url="http://arcanis.name/projects/pytextmonitor"
license=('GPL')
depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools')
depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools' 'sysstat')
optdepends=("hddtemp: for HDD temperature monitor"
"catalyst: for GPU monitor"
"nvidia-utils: for GPU monitor")
"nvidia-utils: for GPU monitor"
"amarok: for music player monitor"
"mpd: for music player monitor"
"qmmp: for music player monitor")
makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}.plasmoid
https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_dtengine}-${_dtver}.zip)
install=${pkgname}.install
md5sums=('988704016573b215bb36b62762075fee'
'3182acdadb3b498be929b3cadad92206')
md5sums=('7fef048a8e000ccf9a1e5f0924f59cc2'
'74f42444a2bddce898d462045c3dbd44')
backup=('usr/share/config/extsysmon.conf')
build ()
{
build () {
# build dataengine
if [[ -d ${srcdir}/${_dtengine}/build ]]; then
rm -rf "${srcdir}/${_dtengine}/build"
fi
mkdir "${srcdir}/${_dtengine}/build"; cd "${srcdir}/${_dtengine}/build"
mkdir "${srcdir}/${_dtengine}/build"
cd "${srcdir}/${_dtengine}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` \
../
make
}
package()
{
package() {
# install dataengine
cd "${srcdir}/${_dtengine}/build"
make DESTDIR="${pkgdir}" install

36
README
View File

@ -1,36 +0,0 @@
py-text-monitor
=============
PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm.
HOWTO
For edited output you must open Settings window and setup output format in lines:
label "$uptime" means uptime, ---d--h--m
label "$cpu" means total load cpu, %
label "$ccpu" means load CPU for each core, %
label "$cpucl" - average cpu clock, MHz
label "$ccpucl" - cpu clock for each core, MHz
label "$temp" - average temperature in system
label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed
label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
label "$mem" - usage memory, %
label "$memmb" - usage memory, MB
label "$swap" - swap, %
label "$swapmb" - swap, MB
label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed
label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature
label "$net" - download and upload speed, KB/s. You may specify network device: something like @@eth0@@
label "$netdev" - current network device
label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent
label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online
Label order will changed if you change slider position. HTML tags in label work normally.
Attention: you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label.
Dependencies:
kdebindings-python2
ext-sysmon (for GPU, GPU temp and HDD temp labels)
lm_sensors (for definition temperature device)
net-tools (for definition network device)

108
README.md Normal file
View File

@ -0,0 +1,108 @@
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 default format. For example, `fri Nov 6 04:48:01 2013`
* label `$isotime` - time in iso format
* label `$shorttime` - time in short locale format
* label `$longtime` - time in long locale format
* 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 `$album` - current song album. One of supported music players must be installed
* label `$progress` - current song progress. One of supported music players must be installed (mpd does not support yet)
* label `$time` - current song duration. 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>.
DataEngine configuration
------------------------
You may edit DataEngine configuration. It is `/usr/share/config/extsysmon.conf` or `$HOME/share/config/extsysmon.conf` depending on the type of installation. Uncomment needed line and edit it.
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

6
TODO
View File

@ -1,6 +0,0 @@
1. Tooltip (graphical information):
a) cpu, %
b) cpuclock, mhz
c) memory, %
d) swap, %
e) network, %

BIN
ext-sysmon-1.6.zip Normal file

Binary file not shown.

View File

@ -14,11 +14,13 @@ include_directories (${CMAKE_SOURCE_DIR}
set (PLUGIN_NAME ${PROJECT_NAME})
file (GLOB PROJECT_DESKTOP *.desktop)
file (GLOB PROJECT_SRCS *.cpp)
file (GLOB PROJECT_CONF *.conf)
# 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})
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install (FILES ${PROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
install (FILES ${PROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})

13
ext-sysmon/extsysmon.conf Normal file
View File

@ -0,0 +1,13 @@
# Configuration file for Extended Systemmonitor DataEngine (v.1.6)
# Uncomment needed lines
# Set GPU device
# May be 'nvidia' (for nvidia), 'ati' (for ATI RADEON), 'ignore' or 'auto'
#GPUDEV=auto
# Set block device for hddtemp comma separated or use 'all'
#HDDDEV=all
# Set MPD settings
#MPDADDRESS=localhost
#MPDPORT=6600

View File

@ -1,8 +1,31 @@
/***************************************************************************
* 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 <QFile>
#include <QProcess>
#include <stdio.h>
#include <stdlib.h>
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args)
@ -10,29 +33,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& 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);
readConfiguration();
}
QStringList ExtendedSysMon::sources() const
@ -41,9 +42,85 @@ QStringList ExtendedSysMon::sources() const
source.append(QString("gpu"));
source.append(QString("gputemp"));
source.append(QString("hddtemp"));
source.append(QString("player"));
return source;
}
bool ExtendedSysMon::readConfiguration()
{
// pre-setup
FILE *f_out;
f_out = popen("lspci 2> /dev/null", "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] 2> /dev/null ; ls -1 /dev/hd[a-z] 2> /dev/null", "r");
while (fgets(device, 256, f_out) != NULL) {
dev = QString(device).split("\n")[0];
if (dev[0] == '/')
hddDev.append(dev);
}
pclose(f_out);
mpdAddress = QString("localhost");
mpdPort = QString("6600");
QString fileStr;
// FIXME: define configuration file
QString confFileName = QString(getenv("HOME")) + QString("/.kde4/share/config/extsysmon.conf");
QFile confFile(confFileName);
bool exists = confFile.open(QIODevice::ReadOnly);
if (!exists) {
confFileName = QString("/usr/share/config/extsysmon.conf");
confFile.setFileName(confFileName);
exists = confFile.open(QIODevice::ReadOnly);
if (!exists)
return false;
}
while (true) {
fileStr = QString(confFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("GPUDEV")) {
if (fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0] == QString("ati"))
gpuDev = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0] == QString("nvidia"))
gpuDev = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0] != QString("auto"))
gpuDev = QString("ignore");
}
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("HDDDEV")) {
if (fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0] != QString("all")) {
hddDev.clear();
for (int i=0; i<fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), \
QString::SkipEmptyParts)[0].split(QString(","), QString::SkipEmptyParts).count(); i++)
hddDev.append(fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), \
QString::SkipEmptyParts)[0].split(QString(","), QString::SkipEmptyParts)[i]);
}
}
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("MPDADDRESS"))
mpdAddress = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("MPDPORT"))
mpdPort = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
}
if (confFile.atEnd())
break;
}
confFile.close();
return true;
}
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
{
return updateSourceEvent(name);
@ -55,41 +132,35 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
QString key, out, tmp_out, value;
bool ok = false;
char output[256], val[5];
if (source == QString("gpu"))
{
if (source == QString("gpu")) {
key = QString("GPU");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1 2>&1", "r");
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
{
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 | grep load | tail -n1 2>&1", "r");
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
{
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
{
else {
value = QString(" N\\A");
}
if (ok == false)
@ -97,41 +168,35 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("gputemp"))
{
else if (source == QString("gputemp")) {
key = QString("GPUTemp");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1 2>&1", "r");
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
{
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 | grep Temperature | tail -n1 2>&1", "r");
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
{
else {
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[4];
sprintf (val, "%4.1f", out.toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else
{
else {
value = QString(" N\\A");
}
if (ok == false)
@ -139,22 +204,19 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("hddtemp"))
{
else if (source == QString("hddtemp")) {
char command[256], *dev;
QByteArray qb;
for (int i=0; i<hdddev.count(); i++)
{
qb = hdddev[i].toUtf8();
for (int i=0; i<hddDev.count(); i++) {
qb = hddDev[i].toUtf8();
dev = qb.data();
sprintf(command, "hddtemp %s", dev);
sprintf(command, "sudo 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
{
else {
out = QString(output).split(QString(":"), QString::SkipEmptyParts)[2];
sprintf (val, "%4.1f", out.left(out.count()-4).toFloat(&ok));
value = QString(val);
@ -163,13 +225,127 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, hdddev[i], value);
setData(source, hddDev[i], value);
}
}
else if (source == QString("player")) {
QProcess player;
QString qoutput;
QString value_album, value_artist, value_progress, value_duration, qstr;
// qmmp
qoutput = QString("");
value = QString("N\\A");
value_album = QString("N\\A");
value_artist = QString("N\\A");
value_progress = QString("0");
value_duration = QString("0");
player.start("qmmp --status");
player.waitForFinished(-1);
qoutput = player.readAllStandardOutput();
for (int i=0; i<qoutput.split(QString("\n"), QString::SkipEmptyParts).count(); i++) {
qstr = qoutput.split(QString("\n"), QString::SkipEmptyParts)[i];
if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("ALBUM"))
value_album = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("ARTIST"))
value_artist = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.at(0) == QChar('[')) {
QString time = qstr.split(QString(" "), QString::SkipEmptyParts)[2].split(QString("\n"), QString::SkipEmptyParts)[0];
value_progress = QString::number(time.split(QString("/"), QString::SkipEmptyParts)[0].split(QString(":"), QString::SkipEmptyParts)[0].toInt() * 60 +
time.split(QString("/"), QString::SkipEmptyParts)[0].split(QString(":"), QString::SkipEmptyParts)[1].toInt());
value_duration = QString::number(time.split(QString("/"), QString::SkipEmptyParts)[1].split(QString(":"), QString::SkipEmptyParts)[0].toInt() * 60 +
time.split(QString("/"), QString::SkipEmptyParts)[1].split(QString(":"), QString::SkipEmptyParts)[1].toInt());
}
else if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("TITLE"))
value = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
key = QString("qmmp_album");
setData(source, key, value_album);
key = QString("qmmp_artist");
setData(source, key, value_artist);
key = QString("qmmp_progress");
setData(source, key, value_progress);
key = QString("qmmp_duration");
setData(source, key, value_duration);
key = QString("qmmp_title");
setData(source, key, value);
// amarok
qoutput = QString("");
value = QString("N\\A");
value_album = QString("N\\A");
value_artist = QString("N\\A");
value_progress = QString("0");
value_duration = QString("0");
player.start("qdbus org.kde.amarok /Player GetMetadata");
player.waitForFinished(-1);
qoutput = player.readAllStandardOutput();
for (int i=0; i<qoutput.split(QString("\n"), QString::SkipEmptyParts).count(); i++) {
qstr = qoutput.split(QString("\n"), QString::SkipEmptyParts)[i];
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
value_album = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
value_artist = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
value_duration = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
value = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
player.start("qdbus org.kde.amarok /Player PositionGet");
player.waitForFinished(-1);
qoutput = player.readAllStandardOutput();
for (int i=0; i<qoutput.split(QString("\n"), QString::SkipEmptyParts).count(); i++) {
qstr = qoutput.split(QString("\n"), QString::SkipEmptyParts)[i];
int time = qstr.toInt() / 1000;
value_progress = QString::number(time);
}
key = QString("amarok_album");
setData(source, key, value_album);
key = QString("amarok_artist");
setData(source, key, value_artist);
key = QString("amarok_progress");
setData(source, key, value_progress);
key = QString("amarok_duration");
setData(source, key, value_duration);
key = QString("amarok_title");
setData(source, key, value);
// mpd
value = QString("N\\A");
value_album = QString("N\\A");
value_artist = QString("N\\A");
value_progress = QString("0");
value_duration = QString("0");
char commandStr[512];
sprintf (commandStr, "echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%s:%s 2> /dev/null", \
mpdAddress.toUtf8().data(), mpdPort.toUtf8().data());
qoutput = QString("");
player.start(QString(commandStr));
player.waitForFinished(-1);
qoutput = player.readAllStandardOutput();
for (int i=0; i<qoutput.split(QString("\n"), QString::SkipEmptyParts).count(); i++) {
qstr = qoutput.split(QString("\n"), QString::SkipEmptyParts)[i];
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
value_album = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
value_artist = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Time"))
value_duration = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
value = qstr.split(QString(": "), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
key = QString("mpd_album");
setData(source, key, value_album);
key = QString("mpd_artist");
setData(source, key, value_artist);
key = QString("mpd_progress");
setData(source, key, value_progress);
key = QString("mpd_duration");
setData(source, key, value_duration);
key = QString("mpd_title");
setData(source, key, value);
}
return true;
}
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
#include "extsysmon.moc"
#include "extsysmon.moc"

View File

@ -1,3 +1,22 @@
/***************************************************************************
* 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
@ -13,9 +32,14 @@ public:
protected:
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList hdddev;
QString gpudev;
bool readConfiguration();
QStringList sources() const;
// main configuration
QStringList hddDev;
QString gpuDev;
// configuration
QString mpdAddress;
QString mpdPort;
};
#endif // EXTSYSMON_H

View File

@ -13,7 +13,7 @@ X-Plasma-EngineName=ext-sysmon
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.2
X-KDE-PluginInfo-Version=1.6
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL

View File

@ -10,13 +10,16 @@ post_install()
{
func_update
cat << EOF
Make sure that \`hddtemp\` can be run as non-root
Make sure that \`hddtemp\` can be run with sudo without password
EOF
}
post_upgrade()
{
func_update
cat << EOF
Make sure that \`hddtemp\` can be run with sudo without password
EOF
}
post_remove()

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,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from util import *

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from PyQt4.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
@ -117,8 +133,16 @@ class ConfigDefinition:
if (self.parent.batBool > 0):
self.parent.label_bat.setText('')
self.parent.layout.removeItem(self.parent.label_bat)
if (self.parent.playerBool > 0):
self.parent.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():
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = ' + str(self.configpage.checkboxes[self.parent.dict_orders[label]].checkState()))
@ -140,6 +164,9 @@ class ConfigDefinition:
elif (self.parent.dict_orders[label] == 'temp'):
self.parent.tempdev = str(self.configpage.ui.comboBox_temp.currentText())
settings.set('temp_device', self.parent.tempdev)
elif (self.parent.dict_orders[label] == 'player'):
self.parent.player_name = self.configpage.ui.comboBox_player.currentIndex()
settings.set('player_name', self.parent.player_name)
self.parent.label_order = ''.join(self.parent.label_order.split('-'))
settings.set('label_order', self.parent.label_order)
@ -186,6 +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)
@ -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,10 +1,27 @@
# -*- 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
from PyKDE4 import plasmascript
import datetime
class DataEngine:
@ -16,9 +33,13 @@ class DataEngine:
def connectToEngine(self):
"""function to initializate engine"""
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
if ((self.parent.gputempBool > 0) or (self.parent.gpuBool > 0) or (self.parent.hddtempBool > 0)):
if ((self.parent.gputempBool > 0) or (self.parent.gpuBool > 0) or (self.parent.hddtempBool > 0) or (self.parent.playerBool > 0)):
self.parent.extsysmon = self.parent.dataEngine("ext-sysmon")
if (self.parent.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 > 0):
@ -59,6 +80,8 @@ class DataEngine:
self.parent.updateNetdev = 0
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
if (self.parent.playerBool > 0):
self.parent.extsysmon.connectSource("player", self.parent, self.parent.interval)
def dataUpdated(self, sourceName, data):
"""function to update data"""
@ -231,7 +254,58 @@ 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):
album = str(data[QString(u'amarok_album')])
artist = str(data[QString(u'amarok_artist')])
progress = str(data[QString(u'amarok_progress')])
time = str(data[QString(u'amarok_duration')])
title = str(data[QString(u'amarok_title')])
elif (self.parent.player_name == 1):
album = str(data[QString(u'mpd_album')])
artist = str(data[QString(u'mpd_artist')])
progress = str(data[QString(u'mpd_progress')])
time = str(data[QString(u'mpd_duration')])
title = str(data[QString(u'mpd_title')])
elif (self.parent.player_name == 2):
album = str(data[QString(u'qmmp_album')])
artist = str(data[QString(u'qmmp_artist')])
progress = str(data[QString(u'qmmp_progress')])
time = str(data[QString(u'qmmp_duration')])
title = str(data[QString(u'qmmp_title')])
line = self.parent.playerFormat
if (line.split('$album')[0] != line):
line = line.split('$album')[0] + album + line.split('$album')[1]
if (line.split('$artist')[0] != line):
line = line.split('$artist')[0] + artist + line.split('$artist')[1]
if (line.split('$progress')[0] != line):
timeText = '%02i:%02i' % (int(time)/60, int(time)%60)
line = line.split('$progress')[0] + timeText + line.split('$progress')[1]
if (line.split('$time')[0] != line):
timeText = '%02i:%02i' % (int(time)/60, int(time)%60)
line = line.split('$time')[0] + timeText + line.split('$time')[1]
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"):
if (self.parent.timeFormat.split('$time')[0] != self.parent.timeFormat):
value = str(data[QString(u'DateTime')].toString(Qt.TextDate).toUtf8())
line = self.parent.timeFormat.split('$time')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$time')[1]
elif (self.parent.timeFormat.split('$isotime')[0] != self.parent.timeFormat):
value = str(data[QString(u'DateTime')].toString(Qt.ISODate).toUtf8())
line = self.parent.timeFormat.split('$isotime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$isotime')[1]
elif (self.parent.timeFormat.split('$shorttime')[0] != self.parent.timeFormat):
value = str(data[QString(u'DateTime')].toString(Qt.SystemLocaleShortDate).toUtf8())
line = self.parent.timeFormat.split('$shorttime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$shorttime')[1]
elif (self.parent.timeFormat.split('$longtime')[0] != self.parent.timeFormat):
value = str(data[QString(u'DateTime')].toString(Qt.SystemLocaleLongDate).toUtf8())
line = self.parent.timeFormat.split('$longtime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$longtime')[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 *
@ -41,7 +57,7 @@ class pyTextWidget(plasmascript.Applet):
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
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)
@ -100,16 +116,19 @@ class pyTextWidget(plasmascript.Applet):
# setup number of cores
commandOut = commands.getoutput("grep -c '^processor' /proc/cpuinfo")
self.numCores = int(commandOut)
self.tempdev = "tempdevice"
# 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"""
@ -168,8 +187,11 @@ class pyTextWidget(plasmascript.Applet):
def memText(self):
"""function to set mem text"""
full = self.mem_uf + self.mem_free
mem = 100 * self.mem_used / full
mem = "%5s" % (str(round(mem, 1)))
try:
mem = 100 * self.mem_used / full
mem = "%5s" % (str(round(mem, 1)))
except:
mem = " N\\A"
if (self.memFormat.split('$mem')[0] != self.memFormat):
line = self.memFormat.split('$mem')[0] + mem + self.memFormat.split('$mem')[1]
else:
@ -181,8 +203,11 @@ class pyTextWidget(plasmascript.Applet):
def swapText(self):
"""function to set swap text"""
full = self.swap_used + self.swap_free
mem = 100 * self.swap_used / full
mem = "%5s" % (str(round(mem, 1)))
try:
mem = 100 * self.swap_used / full
mem = "%5s" % (str(round(mem, 1)))
except:
mem = " N\\A"
if (self.swapFormat.split('$swap')[0] != self.swapFormat):
line = self.swapFormat.split('$swap')[0] + mem + self.swapFormat.split('$swap')[1]
else:

View File

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

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from PyKDE4.kdecore import KComponentData
from PyKDE4.kdeui import KNotification
import commands
@ -43,7 +59,6 @@ class PTMNotify:
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")
print "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]))))
@ -133,6 +148,31 @@ class PTMNotify:
text = text + "%s" %(commands.getoutput("acpi -abi"))
except:
text = "Something wrong"
elif (type == "musicplayer"):
try:
artist = "N\\A"
album = "N\\A"
title = "N\\A"
if (self.parent.parent.player_name == 0):
artist = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-")
album = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep album: | cut -c8-")
title = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep title: | cut -c8-")
elif (self.parent.parent.player_name == 1):
output = commands.getoutput("echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://localhost:6600 2> /dev/null")
for line in output.split("\n"):
if (line.split(": ")[0] == "Artist"):
artist = line.split(": ")[1]
elif (line.split(": ")[0] == "Album"):
album = line.split(": ")[1]
elif (line.split(": ")[0] == "Title"):
title = line.split(": ")[1]
elif (self.parent.parent.player_name == 2):
artist = commands.getoutput("qmmp --nowplaying '%if(%p,%p,Unknown)' 2> /dev/null")
album = commands.getoutput("qmmp --nowplaying '%if(%a,%a,Unknown)' 2> /dev/null")
title = commands.getoutput("qmmp --nowplaying '%if(%t,%t,Unknown)' 2> /dev/null")
text = text + "Artist: %s\nAlbum: %s\nTitle: %s" %(artist, album, title)
except:
text = "Something wrong"
content = [type, text]
return content
@ -140,6 +180,12 @@ class PTMNotify:
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")
@ -212,3 +258,9 @@ class PTMNotify:
return content
except:
pass
try:
if (sender == self.parent.parent.label_player):
content = self.createText("musicplayer")
return content
except:
pass

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2013 Evgeniy Alekseev <esalexeev@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
@ -277,6 +293,36 @@ class Reinit():
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hddtemp.setText(text)
self.parent.layout.addItem(self.parent.label_hddtemp)
elif (order == "d"):
if (self.parent.playerBool > 0):
self.parent.playerFormat = str(settings.get('playerFormat', '[$artist - $title]'))
self.parent.player_name = settings.get('player_name', 0).toInt()[0]
self.parent.label_player = NewPlasmaLabel(self.parent.applet, self.parent)
line = self.parent.playerFormat
if (line.split('$album')[0] != line):
line = line.split('$album')[0] + 'N\\A' + line.split('$album')[1]
if (line.split('$artist')[0] != line):
line = line.split('$artist')[0] + 'N\\A' + line.split('$artist')[1]
if (line.split('$progress')[0] != line):
line = line.split('$progress')[0] + '00:00' + line.split('$progress')[1]
if (line.split('$title') != line):
line = line.split('$title')[0] + 'N\\A' + line.split('$title')[1]
if (line.split('$time') != line):
line = line.split('$time')[0] + '00:00' + line.split('$time')[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)

View File

@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from shutil import copyfile
from PyKDE4.kdecore import *
import os

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>575</width>
<height>500</height>
<height>561</height>
</rect>
</property>
<property name="sizePolicy">
@ -42,6 +42,64 @@
<string>Widget settings</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_time">
<item>
<widget class="QCheckBox" name="checkBox_time">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">Time</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_time">
<property name="toolTip">
<string notr="true">$time - time in default format
$isotime - time in ISO format
$shorttime - time in short format
$longtime - time in log format</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="slider_time">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_uptime">
<item>
@ -82,11 +140,14 @@
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -138,13 +199,13 @@ $ccpu - load CPU for each core, %</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>2</number>
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -197,13 +258,13 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -268,13 +329,13 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>4</number>
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -326,13 +387,13 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>5</number>
<number>6</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -384,13 +445,13 @@ $ccpucl - CPU clock for each core, MHz</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>6</number>
<number>7</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -443,13 +504,13 @@ $memmb - RAM usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>7</number>
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -502,13 +563,13 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>8</number>
<number>9</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -560,13 +621,13 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>9</number>
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -618,13 +679,13 @@ $swapmb - swap usage, MB</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
<number>11</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -678,13 +739,13 @@ $netdev - current network device
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>11</number>
<number>12</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -737,13 +798,13 @@ $ac - AC status</string>
<number>1</number>
</property>
<property name="maximum">
<number>12</number>
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>12</number>
<number>13</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -841,6 +902,93 @@ $ac - AC status</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_player">
<item>
<widget class="QCheckBox" name="checkBox_player">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">Music player</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_player">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>amarok</string>
</property>
</item>
<item>
<property name="text">
<string>mpd</string>
</property>
</item>
<item>
<property name="text">
<string>qmmp</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_player">
<property name="toolTip">
<string notr="true">$album - song album
$artist - song artist
$progress - song progress
$time - song duration
$title - song title</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="slider_player">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>14</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>14</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_elements">
<property name="orientation">
@ -1184,6 +1332,9 @@ $ac - AC status</string>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>checkBox_time</tabstop>
<tabstop>lineEdit_time</tabstop>
<tabstop>slider_time</tabstop>
<tabstop>checkBox_uptime</tabstop>
<tabstop>lineEdit_uptime</tabstop>
<tabstop>slider_uptime</tabstop>
@ -1223,6 +1374,10 @@ $ac - AC status</string>
<tabstop>slider_bat</tabstop>
<tabstop>lineEdit_batdev</tabstop>
<tabstop>lineEdit_acdev</tabstop>
<tabstop>checkBox_player</tabstop>
<tabstop>comboBox_player</tabstop>
<tabstop>lineEdit_player</tabstop>
<tabstop>slider_player</tabstop>
<tabstop>spinBox_interval</tabstop>
<tabstop>fontComboBox</tabstop>
<tabstop>spinBox_fontSize</tabstop>

View File

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