mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-01 16:05:56 +00:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
c198b7596a | |||
1f18e2fe67 | |||
1b3280c464 | |||
2a686f4f1e | |||
4f7cb6aa3c | |||
1323d6d647 | |||
2a2559d507 | |||
c8d7af4026 | |||
034c9eff7a | |||
cda78dbf1d | |||
8007c81129 | |||
10511a8715 | |||
9f77e83685 | |||
17efef871a | |||
669571e803 |
54
PKGBUILD
Normal file
54
PKGBUILD
Normal file
@ -0,0 +1,54 @@
|
||||
# Author: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
|
||||
|
||||
pkgname=kdeplasma-applets-pytextmonitor
|
||||
_pkgname=py-text-monitor
|
||||
pkgver=1.3.5
|
||||
pkgrel=1
|
||||
_dtengine=ext-sysmon
|
||||
_dtver=1.2
|
||||
pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm"
|
||||
arch=('i686' 'x86_64')
|
||||
url="https://github.com/arcan1s/pytextmonitor"
|
||||
license=('GPL')
|
||||
depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools')
|
||||
optdepends=('hddtemp: for HDD temperature monitor'
|
||||
'775bc3a6057f2dc1696f09b8d315a3e9'
|
||||
'775bc3a6057f2dc1696f09b8d315a3e9')
|
||||
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=('d99c8a152693b6b10ebe8fb1a076a333'
|
||||
'775bc3a6057f2dc1696f09b8d315a3e9')
|
||||
|
||||
build ()
|
||||
{
|
||||
# build dataengine
|
||||
if [ -d ${srcdir}/${_dtengine}/build ]; then
|
||||
rm -r ${srcdir}/${_dtengine}/build
|
||||
fi
|
||||
mkdir ${srcdir}/${_dtengine}/build && cd ${srcdir}/${_dtengine}/build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` \
|
||||
../
|
||||
make
|
||||
}
|
||||
|
||||
package()
|
||||
{
|
||||
# install dataengine
|
||||
cd ${srcdir}/${_dtengine}/build
|
||||
make DESTDIR=${pkgdir} install
|
||||
|
||||
# install plasmoid
|
||||
install -D -m644 ${srcdir}/metadata.desktop \
|
||||
${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop
|
||||
install -D -m644 ${srcdir}/metadata.desktop \
|
||||
${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/metadata.desktop
|
||||
mkdir -p ${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/{code,ui}
|
||||
install -m644 ${srcdir}/contents/code/* \
|
||||
-t ${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/code
|
||||
install -m644 ${srcdir}/contents/ui/* \
|
||||
-t ${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/ui
|
||||
}
|
30
create_archive.sh
Executable file
30
create_archive.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# build dataengine
|
||||
ARCHIVE="ext-sysmon"
|
||||
VERSION=`grep Version ext-sysmon/plasma-engine-extsysmon.desktop | awk -F "=" '{print $2}'`
|
||||
# create archive
|
||||
if [ -e ${ARCHIVE}-${VERSION}.zip ]; then
|
||||
rm -f ${ARCHIVE}-${VERSION}.zip
|
||||
fi
|
||||
zip -9 -y -r -q ${ARCHIVE}-${VERSION}.zip ${ARCHIVE}
|
||||
# update md5sum
|
||||
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.zip | awk '{print $1}'`
|
||||
sed -i "/ '[0-9A-Fa-f]*/s/[^'][^)]*/ '${MD5SUMS}'/" PKGBUILD
|
||||
sed -i "s/_dtver=[0-9.]*/_dtver=${VERSION}/" PKGBUILD
|
||||
|
||||
# build widget
|
||||
cd sources
|
||||
FILES="contents metadata.desktop"
|
||||
ARCHIVE="py-text-monitor"
|
||||
VERSION=`grep Version metadata.desktop | awk -F "=" '{print $2}'`
|
||||
# create archive
|
||||
if [ -e ${ARCHIVE}-${VERSION}.plasmoid ]; then
|
||||
rm -f ${ARCHIVE}-${VERSION}.plasmoid
|
||||
fi
|
||||
zip -9 -y -r -q ../${ARCHIVE}-${VERSION}.plasmoid ${FILES}
|
||||
cd ..
|
||||
# update md5sum
|
||||
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.plasmoid | awk '{print $1}'`
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
|
BIN
ext-sysmon-1.2.zip
Normal file
BIN
ext-sysmon-1.2.zip
Normal file
Binary file not shown.
24
ext-sysmon/CMakeLists.txt
Normal file
24
ext-sysmon/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
# set project name
|
||||
project (plasma_engine_extsysmon)
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS}
|
||||
${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES})
|
||||
|
||||
set (PLUGIN_NAME ${PROJECT_NAME})
|
||||
file (GLOB PROJECT_DESKTOP *.desktop)
|
||||
file (GLOB PROJECT_SRCS *.cpp)
|
||||
|
||||
# make
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${PROJECT_SRCS})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
|
||||
# install
|
||||
install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(FILES ${PROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
@ -1,95 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4 import plasmascript
|
||||
import commands
|
||||
|
||||
|
||||
|
||||
class ExtendedSysMon(plasmascript.DataEngine):
|
||||
def __init__(self, parent, args=None):
|
||||
"""dataengine definition"""
|
||||
plasmascript.DataEngine.__init__(self, parent)
|
||||
|
||||
|
||||
def init(self):
|
||||
"""initialization"""
|
||||
self.setMinimumPollingInterval(333)
|
||||
|
||||
# setup gpu device
|
||||
self.gpudev = ''
|
||||
commandOut = commands.getoutput("lspci")
|
||||
if (commandOut.lower().find('nvidia') > -1):
|
||||
self.gpudev = 'nvidia'
|
||||
elif (commandOut.lower().find('radeon') > -1):
|
||||
self.gpudev = 'ati'
|
||||
|
||||
# setup hdd devices
|
||||
self.hdddev = []
|
||||
commandOut = commands.getoutput("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z]")
|
||||
for device in commandOut.split('\n'):
|
||||
if (device[:3] != "ls:"):
|
||||
self.hdddev.append(device)
|
||||
|
||||
|
||||
def sources(self):
|
||||
"""create sources"""
|
||||
sources = ["gpu", "gputemp", "hddtemp"]
|
||||
return sources
|
||||
|
||||
|
||||
def sourceRequestEvent(self, name):
|
||||
return self.updateSourceEvent(name)
|
||||
|
||||
|
||||
def updateSourceEvent(self, source):
|
||||
"""update sources and setup values"""
|
||||
if (source == "gpu"):
|
||||
key = "GPU"
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%5s" % (str(round(float(commandOut.split()[2][:-1]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||
try:
|
||||
value = "%5s" % (str(round(float(commandOut.split()[3][:-1]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
self.setData(source, "GPU", QString(value))
|
||||
elif (source == "gputemp"):
|
||||
if (self.gpudev == 'nvidia'):
|
||||
commandOut = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split()[2]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (self.gpudev == 'ati'):
|
||||
commandOut = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split()[4]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
self.setData(source, "GPUTemp", QString(value))
|
||||
elif (source == "hddtemp"):
|
||||
for device in self.hdddev:
|
||||
commandOut = commands.getoutput("hddtemp " + device)
|
||||
try:
|
||||
value = "%4s" % (str(round(float(commandOut.split(':')[2][:-3]), 1)))
|
||||
except:
|
||||
value = " N\A"
|
||||
self.setData(source, device, QString(value))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def CreateDataEngine(parent):
|
||||
return ExtendedSysMon(parent)
|
175
ext-sysmon/extsysmon.cpp
Normal file
175
ext-sysmon/extsysmon.cpp
Normal file
@ -0,0 +1,175 @@
|
||||
#include "extsysmon.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||
: Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
|
||||
FILE *f_out;
|
||||
f_out = popen("lspci 2>&1", "r");
|
||||
char device[256];
|
||||
QString dev;
|
||||
while (fgets(device, 256, f_out) != NULL)
|
||||
{
|
||||
dev = QString(device);
|
||||
if (dev.toLower().contains("nvidia"))
|
||||
gpudev = QString("nvidia");
|
||||
else if (dev.toLower().contains("radeon"))
|
||||
gpudev = QString("ati");
|
||||
}
|
||||
pclose(f_out);
|
||||
|
||||
f_out = popen("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z] 2>&1", "r");
|
||||
while (fgets(device, 256, f_out) != NULL)
|
||||
{
|
||||
dev = QString(device);
|
||||
if (dev[0] == '/')
|
||||
hdddev.append(dev);
|
||||
}
|
||||
pclose(f_out);
|
||||
}
|
||||
|
||||
QStringList ExtendedSysMon::sources() const
|
||||
{
|
||||
QStringList source;
|
||||
source.append(QString("gpu"));
|
||||
source.append(QString("gputemp"));
|
||||
source.append(QString("hddtemp"));
|
||||
return source;
|
||||
}
|
||||
|
||||
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
{
|
||||
FILE *f_out;
|
||||
QString key, out, tmp_out, value;
|
||||
bool ok = false;
|
||||
char output[256], val[5];
|
||||
if (source == QString("gpu"))
|
||||
{
|
||||
key = QString("GPU");
|
||||
if (gpudev == QString("nvidia"))
|
||||
{
|
||||
f_out = popen("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1 2>&1", "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 | grep load | tail -n1 2>&1", "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 | grep Gpu | tail -n1 2>&1", "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 | grep Temperature | tail -n1 2>&1", "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", 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);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
|
||||
|
||||
#include "extsysmon.moc"
|
21
ext-sysmon/extsysmon.h
Normal file
21
ext-sysmon/extsysmon.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef EXTSYSMON_H
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
class ExtendedSysMon : public Plasma::DataEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList hdddev;
|
||||
QString gpudev;
|
||||
QStringList sources() const;
|
||||
};
|
||||
|
||||
#endif // EXTSYSMON_H
|
@ -6,14 +6,14 @@ ServiceTypes=Plasma/DataEngine
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_extsysmon
|
||||
X-Plasma-EngineName=ext-sysmon
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=ext-sysmon
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Version=1.2
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
20
kdeplasma-applets-pytextmonitor.install
Normal file
20
kdeplasma-applets-pytextmonitor.install
Normal file
@ -0,0 +1,20 @@
|
||||
post_install()
|
||||
{
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
cat << EOF
|
||||
Make sure that \`hddtemp\` can be run as non-root
|
||||
EOF
|
||||
}
|
||||
|
||||
post_upgrade()
|
||||
{
|
||||
post_install
|
||||
}
|
||||
|
||||
post_remove()
|
||||
{
|
||||
post_install
|
||||
}
|
Binary file not shown.
BIN
py-text-monitor-1.3.5.plasmoid
Normal file
BIN
py-text-monitor-1.3.5.plasmoid
Normal file
Binary file not shown.
@ -69,8 +69,8 @@ class pyTextWidget(plasmascript.Applet):
|
||||
try:
|
||||
interfaces = []
|
||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||
if ((line != '') and (line[0] != ' ') and (line[0:3] != 'lo:')):
|
||||
interfaces.append(line.split(":")[0])
|
||||
if ((line != '') and (line[0] != ' ') and (line.split(":")[0].split()[0] != 'lo')):
|
||||
interfaces.append(line.split(":")[0].split()[0])
|
||||
|
||||
for device in interfaces:
|
||||
if (commands.getoutput("ifconfig " + device + " | grep 'inet '") != ''):
|
@ -277,13 +277,8 @@ class Reinit():
|
||||
self.parent.resize(10,10)
|
||||
|
||||
# create dataengines
|
||||
label_start = True
|
||||
while label_start:
|
||||
try:
|
||||
self.parent.dataengine.connectToEngine()
|
||||
label_start = False
|
||||
except:
|
||||
pass
|
||||
self.parent.thread().wait(60000)
|
||||
self.parent.dataengine.connectToEngine()
|
||||
|
||||
self.parent.timer.setInterval(self.parent.interval)
|
||||
self.parent.startPolling()
|
@ -9,10 +9,10 @@ X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
X-Plasma-RequiredExtensions=LaunchApp,LocalIO,FileDialog
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=py-text-monitor
|
||||
X-KDE-PluginInfo-Version=1.3.4
|
||||
X-KDE-PluginInfo-Version=1.3.5
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
Reference in New Issue
Block a user