mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
edited file tree
This commit is contained in:
parent
037faa8a56
commit
24324917c4
16
PKGBUILD
16
PKGBUILD
@ -1,5 +1,4 @@
|
|||||||
# Author: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||||
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
|
||||||
|
|
||||||
pkgname=kdeplasma-applets-netctl-monitor
|
pkgname=kdeplasma-applets-netctl-monitor
|
||||||
_pkgname=netctl-monitor
|
_pkgname=netctl-monitor
|
||||||
@ -14,16 +13,21 @@ makedepends=('cmake' 'automoc4')
|
|||||||
source=(https://github.com/arcan1s/netctlmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
source=(https://github.com/arcan1s/netctlmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||||
install=${pkgname}.install
|
install=${pkgname}.install
|
||||||
md5sums=('d3ab03ddea1e4793cfc5f35a0f7a5ff1')
|
md5sums=('d3ab03ddea1e4793cfc5f35a0f7a5ff1')
|
||||||
|
_cmakekeys="-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
|
||||||
|
-DBUILD_GUI:BOOL=1
|
||||||
|
-DBUILD_PLASMOID:BOOL=1
|
||||||
|
-DCMAKE_BUILD_TYPE=Release"
|
||||||
|
|
||||||
build () {
|
prepare() {
|
||||||
if [[ -d ${srcdir}/build ]]; then
|
if [[ -d ${srcdir}/build ]]; then
|
||||||
rm -rf "${srcdir}/build"
|
rm -rf "${srcdir}/build"
|
||||||
fi
|
fi
|
||||||
mkdir "${srcdir}/build"
|
mkdir "${srcdir}/build"
|
||||||
|
}
|
||||||
|
|
||||||
|
build () {
|
||||||
cd "${srcdir}/build"
|
cd "${srcdir}/build"
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
cmake ${_cmakekeys} ../${_pkgname}
|
||||||
-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` \
|
|
||||||
../${_pkgname}
|
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
kdeplasma-applets-netctl-monitor.install
Normal file
13
kdeplasma-applets-netctl-monitor.install
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
post_install() {
|
||||||
|
kbuildsycoca4 > /dev/null 2>&1
|
||||||
|
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
|
||||||
|
update-desktop-database -q
|
||||||
|
}
|
||||||
|
|
||||||
|
post_upgrade() {
|
||||||
|
post_install
|
||||||
|
}
|
||||||
|
|
||||||
|
post_remove() {
|
||||||
|
post_install
|
||||||
|
}
|
@ -14,9 +14,6 @@ configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/ver
|
|||||||
|
|
||||||
message (STATUS "Version ${PROJECT_VERSION}")
|
message (STATUS "Version ${PROJECT_VERSION}")
|
||||||
|
|
||||||
set (COMPS netctl-gui
|
|
||||||
netctl-monitor)
|
|
||||||
|
|
||||||
# install options
|
# install options
|
||||||
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
|
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
|
||||||
option (BUILD_GUI "Build GUI" ON)
|
option (BUILD_GUI "Build GUI" ON)
|
||||||
@ -29,7 +26,7 @@ set (CMAKE_VERBOSE_MAKEFILE ON)
|
|||||||
if ( WITH_DEBUG_MODE )
|
if ( WITH_DEBUG_MODE )
|
||||||
add_definitions ( -DDEBUG_MODE=1 )
|
add_definitions ( -DDEBUG_MODE=1 )
|
||||||
endif ()
|
endif ()
|
||||||
if ( CMAKE_COMPILER_IS_GNUCXX )
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set (ADD_CXX_FLAGS "-Wall")
|
set (ADD_CXX_FLAGS "-Wall")
|
||||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
@ -38,6 +35,10 @@ else ()
|
|||||||
message ("Unknown compiler")
|
message ("Unknown compiler")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
foreach (COMP ${COMPS})
|
if (BUILD_GUI)
|
||||||
add_subdirectory (${COMP})
|
add_subdirectory (netctl-gui)
|
||||||
endforeach ()
|
endif ()
|
||||||
|
if (BUILD_PLASMOID)
|
||||||
|
add_subdirectory (netctl-dataengine)
|
||||||
|
add_subdirectory (netctl-monitor)
|
||||||
|
endif ()
|
||||||
|
27
sources/netctl-dataengine/CMakeLists.txt
Normal file
27
sources/netctl-dataengine/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# set project name
|
||||||
|
set (SUBPROJECT plasma_engine_netctl-dataengine)
|
||||||
|
|
||||||
|
# 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}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||||
|
|
||||||
|
set (PLUGIN_NAME ${SUBPROJECT})
|
||||||
|
file (GLOB SUBPROJECT_DESKTOP *.desktop)
|
||||||
|
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||||
|
file (GLOB SUBPROJECT_CONF *.conf)
|
||||||
|
|
||||||
|
# make
|
||||||
|
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||||
|
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||||
|
|
||||||
|
# install
|
||||||
|
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
|
install (FILES ${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||||
|
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
13
sources/netctl-dataengine/extsysmon.conf
Normal file
13
sources/netctl-dataengine/extsysmon.conf
Normal 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
|
329
sources/netctl-dataengine/extsysmon.cpp
Normal file
329
sources/netctl-dataengine/extsysmon.cpp
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
Q_UNUSED(args)
|
||||||
|
|
||||||
|
setMinimumPollingInterval(333);
|
||||||
|
readConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
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::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 (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.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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
confFile.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"))
|
||||||
|
{
|
||||||
|
QProcess player;
|
||||||
|
QString qoutput;
|
||||||
|
// qmmp
|
||||||
|
qoutput = QString("");
|
||||||
|
key = QString("qmmp_artist");
|
||||||
|
player.start("qmmp --nowplaying %if(%p,%p,Unknown)");
|
||||||
|
player.waitForFinished(-1);
|
||||||
|
qoutput = player.readAllStandardOutput();
|
||||||
|
if (qoutput == QString(""))
|
||||||
|
value = QString("N\\A");
|
||||||
|
else
|
||||||
|
value = qoutput.split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||||
|
setData(source, key, value);
|
||||||
|
qoutput = QString("");
|
||||||
|
key = QString("qmmp_title");
|
||||||
|
player.start("qmmp --nowplaying %if(%t,%t,Unknown)");
|
||||||
|
player.waitForFinished(-1);
|
||||||
|
qoutput = player.readAllStandardOutput();
|
||||||
|
if (qoutput == QString(""))
|
||||||
|
value = QString("N\\A");
|
||||||
|
else
|
||||||
|
value = qoutput.split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||||
|
setData(source, key, value);
|
||||||
|
// amarok
|
||||||
|
QString value_artist, qstr;
|
||||||
|
qoutput = QString("");
|
||||||
|
value = QString("N\\A");
|
||||||
|
value_artist = QString("N\\A");
|
||||||
|
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("artist"))
|
||||||
|
value_artist = 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("amarok_artist");
|
||||||
|
setData(source, key, value_artist);
|
||||||
|
key = QString("amarok_title");
|
||||||
|
setData(source, key, value);
|
||||||
|
// mpd
|
||||||
|
value = QString("N\\A");
|
||||||
|
value_artist = QString("N\\A");
|
||||||
|
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("Artist"))
|
||||||
|
value_artist = 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_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"
|
45
sources/netctl-dataengine/extsysmon.h
Normal file
45
sources/netctl-dataengine/extsysmon.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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);
|
||||||
|
bool readConfiguration();
|
||||||
|
QStringList sources() const;
|
||||||
|
// main configuration
|
||||||
|
QStringList hdddev;
|
||||||
|
QString gpudev;
|
||||||
|
// configuration
|
||||||
|
QString mpdAddress;
|
||||||
|
QString mpdPort;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EXTSYSMON_H
|
20
sources/netctl-dataengine/plasma-engine-extsysmon.desktop
Normal file
20
sources/netctl-dataengine/plasma-engine-extsysmon.desktop
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=Extended SystemMonitor DataEngine
|
||||||
|
Comment=Adds gpu, gputemp and hddtemp to DataEngine
|
||||||
|
ServiceTypes=Plasma/DataEngine
|
||||||
|
Type=Service
|
||||||
|
Icon=utilities-system-monitor
|
||||||
|
|
||||||
|
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||||
|
X-KDE-Library=plasma_engine_extsysmon
|
||||||
|
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.6
|
||||||
|
X-KDE-PluginInfo-Category=System Information
|
||||||
|
X-KDE-PluginInfo-Depends=
|
||||||
|
X-KDE-PluginInfo-License=GPL
|
||||||
|
X-KDE-PluginInfo-EnabledByDefault=true
|
Loading…
Reference in New Issue
Block a user