diff --git a/PKGBUILD b/PKGBUILD
index 321b12b..7dcfea9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,13 +3,13 @@
pkgname=kdeplasma-applets-pytextmonitor
_pkgname=py-text-monitor
-pkgver=1.5.2
+pkgver=1.5.3
pkgrel=1
_dtengine=ext-sysmon
-_dtver=1.5
+_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' 'sysstat')
optdepends=("hddtemp: for HDD temperature monitor"
@@ -22,25 +22,24 @@ 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=('62a83e665d5a60e40891357a237cea1c'
- 'e8c0e40298facf6f515f3c72c66b2aa0')
+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
diff --git a/README.md b/README.md
index d0d4ccb..cff5609 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,8 @@ For edited output you must open Settings window and setup output format in lines
* label `$bat` - battery charge, %. Battery device may be set below. File (`/sys/class/power_supply/BAT0/capacity` by default) must contain only battery charge in percent
* label `$ac` - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle (`/sys/class/power_supply/AC/online` by default) must contain `1` if AC is online
* label `$artist` - current song artist. One of supported music players must be installed
+* label `$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.
diff --git a/ext-sysmon-1.5.zip b/ext-sysmon-1.5.zip
deleted file mode 100644
index c9e4c03..0000000
Binary files a/ext-sysmon-1.5.zip and /dev/null differ
diff --git a/ext-sysmon-1.6.zip b/ext-sysmon-1.6.zip
new file mode 100644
index 0000000..22b1833
Binary files /dev/null and b/ext-sysmon-1.6.zip differ
diff --git a/ext-sysmon/extsysmon.conf b/ext-sysmon/extsysmon.conf
index 343daec..8bcaf13 100644
--- a/ext-sysmon/extsysmon.conf
+++ b/ext-sysmon/extsysmon.conf
@@ -1,4 +1,4 @@
-# Configuration file for Extended Systemmonitor DataEngine (v.1.5)
+# Configuration file for Extended Systemmonitor DataEngine (v.1.6)
# Uncomment needed lines
# Set GPU device
diff --git a/ext-sysmon/extsysmon.cpp b/ext-sysmon/extsysmon.cpp
index 5af776d..708e635 100644
--- a/ext-sysmon/extsysmon.cpp
+++ b/ext-sysmon/extsysmon.cpp
@@ -1,26 +1,27 @@
/***************************************************************************
- * Copyright (C) 2013 by Evgeniy Alekseev *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
- ***************************************************************************/
+* Copyright (C) 2013 by Evgeniy Alekseev *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
+***************************************************************************/
#include "extsysmon.h"
#include
#include
+#include
#include
#include
@@ -52,22 +53,20 @@ bool ExtendedSysMon::readConfiguration()
f_out = popen("lspci 2> /dev/null", "r");
char device[256];
QString dev;
- while (fgets(device, 256, f_out) != NULL)
- {
+ 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");
+ 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)
- {
+ while (fgets(device, 256, f_out) != NULL) {
dev = QString(device).split("\n")[0];
if (dev[0] == '/')
- hdddev.append(dev);
+ hddDev.append(dev);
}
pclose(f_out);
@@ -79,8 +78,7 @@ bool ExtendedSysMon::readConfiguration()
QString confFileName = QString(getenv("HOME")) + QString("/.kde4/share/config/extsysmon.conf");
QFile confFile(confFileName);
bool exists = confFile.open(QIODevice::ReadOnly);
- if (!exists)
- {
+ if (!exists) {
confFileName = QString("/usr/share/config/extsysmon.conf");
confFile.setFileName(confFileName);
exists = confFile.open(QIODevice::ReadOnly);
@@ -88,32 +86,24 @@ bool ExtendedSysMon::readConfiguration()
return false;
}
- while (true)
- {
+ while (true) {
fileStr = QString(confFile.readLine());
- if (confFile.atEnd())
- break;
- else if (fileStr[0] != '#')
- {
- if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
- {
- if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("GPUDEV"))
- {
+ 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];
+ 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];
+ 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");
+ 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();
+ 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 /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"))
- {
+ 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)
@@ -182,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"))
- {
+ 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"))
- {
+ 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)
@@ -224,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 /dev/null", 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);
@@ -248,74 +225,120 @@ 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"))
- {
+ else if (source == QString("player")) {
+ QProcess player;
+ QString qoutput;
+ QString value_album, value_artist, value_progress, value_duration, qstr;
// qmmp
- output[0] = '\0';
+ 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 /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';
+ 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");
- 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';
+ 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 /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';
+ 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");
- 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_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());
- f_out = popen(commandStr, "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];
+ mpdAddress.toUtf8().data(), mpdPort.toUtf8().data());
+ qoutput = QString("");
+ player.start(QString(commandStr));
+ player.waitForFinished(-1);
+ qoutput = player.readAllStandardOutput();
+ for (int i=0; i 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
+ 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]
diff --git a/sources/contents/code/main.py b/sources/contents/code/main.py
index 444735a..366bbff 100644
--- a/sources/contents/code/main.py
+++ b/sources/contents/code/main.py
@@ -116,6 +116,7 @@ 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',
diff --git a/sources/contents/code/reinit.py b/sources/contents/code/reinit.py
index 3030cbe..79f0694 100644
--- a/sources/contents/code/reinit.py
+++ b/sources/contents/code/reinit.py
@@ -298,12 +298,17 @@ class Reinit():
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
+ 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] + '----------' + line.split('$title')[1]
+ 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)
diff --git a/sources/contents/ui/configwindow.ui b/sources/contents/ui/configwindow.ui
index 1712806..a0e1db6 100644
--- a/sources/contents/ui/configwindow.ui
+++ b/sources/contents/ui/configwindow.ui
@@ -948,8 +948,11 @@ $ac - AC status
-
- $title - song title
-$artist - song artist
+ $album - song album
+$artist - song artist
+$progress - song progress
+$time - song duration
+$title - song title
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
diff --git a/sources/metadata.desktop b/sources/metadata.desktop
index 556f145..ef8dfa3 100644
--- a/sources/metadata.desktop
+++ b/sources/metadata.desktop
@@ -12,7 +12,7 @@ X-Plasma-RequiredExtensions=LaunchApp,LocalIO,FileDialog
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=py-text-monitor
-X-KDE-PluginInfo-Version=1.5.2
+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=