mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
New release 1.2.0
widget: + added $ac label - return (*) if AC is online or ( ) if offline + error cheking * $bat now reading from /sys/* config: + added battery and ac device configurations
This commit is contained in:
parent
9ccf1b597a
commit
9e708c6660
@ -1,16 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from util import *
|
||||
|
||||
|
||||
|
||||
class Config():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
self.config = self.applet.globalConfig()
|
||||
|
||||
def get(self, key, default = ''):
|
||||
return self.config.readEntry(key, default).toString()
|
||||
|
||||
def set(self, key, value):
|
||||
self.config.writeEntry(key, value)
|
@ -1,15 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
from PyKDE4 import plasmascript
|
||||
|
||||
|
||||
|
||||
class ConfigWindow(QWidget):
|
||||
def __init__(self, parent, settings):
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)
|
||||
self.parent = parent
|
@ -1,244 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
from PyKDE4.kio import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
from PyKDE4 import plasmascript
|
||||
from PyQt4 import QtCore
|
||||
from configwindow import *
|
||||
from config import *
|
||||
from util import *
|
||||
import commands, os, time
|
||||
|
||||
|
||||
|
||||
class pyTextWidget(plasmascript.Applet):
|
||||
def __init__(self,parent, args=None):
|
||||
"""widget definition"""
|
||||
plasmascript.Applet.__init__(self,parent)
|
||||
|
||||
def init(self):
|
||||
"""function to initializate widget"""
|
||||
self._name = str(self.package().metadata().pluginName())
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
self.setHasConfigurationInterface(True)
|
||||
|
||||
self.label = Plasma.Label(self.applet)
|
||||
self.label.setText("N\A")
|
||||
self.layout.addItem(self.label)
|
||||
self.applet.setLayout(self.layout)
|
||||
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
|
||||
#initial configuration
|
||||
self.settings = Config(self)
|
||||
self.format = str(self.settings.get('format', '[cpu: $cpu%][temp: $temp°C][mem: $mem%][swap: $swap%][net: $netKB/s][bat: $bat%]'))
|
||||
self.interval = int(self.settings.get('interval', '2000'))
|
||||
self.font_family = str(self.settings.get('font_family', 'Terminus'))
|
||||
self.font_size = int(self.settings.get('font_size', 12))
|
||||
self.font_color = str(self.settings.get('font_color', '#000000'))
|
||||
self.font_style = str(self.settings.get('font_style', 'normal'))
|
||||
self.num_dev = int(self.settings.get('num_dev', 0))
|
||||
|
||||
self.resize(250,10)
|
||||
|
||||
# start timer
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(self.interval)
|
||||
self.startPolling()
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
# update local variables
|
||||
self.format = str(self.configpage.ui.lineEdit_format.text())
|
||||
self.interval = int(self.configpage.ui.spinBox_interval.value())
|
||||
self.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
|
||||
self.font_size = int(self.configpage.ui.spinBox_fontSize.value())
|
||||
self.font_color = str(self.configpage.ui.kcolorcombo.color().name())
|
||||
self.font_style = str(self.configpage.ui.lineEdit_style.text())
|
||||
self.num_dev = int(self.configpage.ui.comboBox_numNet.currentIndex())
|
||||
|
||||
# save config to settings
|
||||
self.settings.set('format', self.format)
|
||||
self.settings.set('interval', self.interval)
|
||||
self.settings.set('font_family', self.font_family)
|
||||
self.settings.set('font_size', self.font_size)
|
||||
self.settings.set('font_color', self.font_color)
|
||||
self.settings.set('font_style', self.font_style)
|
||||
self.settings.set('num_dev', self.num_dev)
|
||||
|
||||
# update timer
|
||||
self.timer.setInterval(self.interval)
|
||||
self.startPolling()
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
self.configpage = ConfigWindow(self, self.settings)
|
||||
|
||||
font = QFont(str(self.settings.get('font_family', 'Terminus')), int(self.settings.get('font_size', 12)), int(int(self.settings.get('font_weight', 50))))
|
||||
self.configpage.ui.lineEdit_format.setText(str(self.settings.get('format', '[cpu: $cpu%][temp: $temp°C][mem: $mem%][swap: $swap%][net: $netKB/s][bat: $bat%]')))
|
||||
self.configpage.ui.spinBox_interval.setValue(int(self.settings.get('interval', '2000')))
|
||||
self.configpage.ui.fontComboBox.setCurrentFont(font)
|
||||
self.configpage.ui.spinBox_fontSize.setValue(int(self.settings.get('font_size', 12)))
|
||||
self.configpage.ui.kcolorcombo.setColor(QColor(str(self.settings.get('font_color', '#000000'))))
|
||||
self.configpage.ui.lineEdit_style.setText(str(self.settings.get('font_style', 'normal')))
|
||||
self.configpage.ui.comboBox_numNet.setCurrentIndex(int(self.settings.get('num_dev', 0)))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.name()))
|
||||
page.setIcon(KIcon(self.icon()))
|
||||
|
||||
parent.okClicked.connect(self.configAccepted)
|
||||
|
||||
def formating_line(self):
|
||||
"""function to set format line"""
|
||||
output = self.format
|
||||
|
||||
if (output.split("$cpu")[0] != output):
|
||||
output = output.split("$cpu")[0] + self.cpuText() + output.split("$cpu")[1]
|
||||
if (output.split("$temp")[0] != output):
|
||||
output = output.split("$temp")[0] + self.tempText() + output.split("$temp")[1]
|
||||
if (output.split("$mem")[0] != output):
|
||||
output = output.split("$mem")[0] + self.memText() + output.split("$mem")[1]
|
||||
if (output.split("$swap")[0] != output):
|
||||
output = output.split("$swap")[0] + self.swapText() + output.split("$swap")[1]
|
||||
if (output.split("$net")[0] != output):
|
||||
output = output.split("$net")[0] + self.netText() + output.split("$net")[1]
|
||||
if (output.split("$bat")[0] != output):
|
||||
output = output.split("$bat")[0] + self.batText() + output.split("$bat")[1]
|
||||
|
||||
return output
|
||||
|
||||
def showConfigurationInterface(self):
|
||||
"""function to show configuration window"""
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
|
||||
def showTooltip(self, text):
|
||||
"""function to create and set tooltip"""
|
||||
tooltip = Plasma.ToolTipContent()
|
||||
tooltip.setImage(KIcon(self.icon()))
|
||||
tooltip.setSubText(text)
|
||||
tooltip.setAutohide(False)
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, tooltip)
|
||||
Plasma.ToolTipManager.self().registerWidget(self.applet)
|
||||
|
||||
def startPolling(self):
|
||||
try:
|
||||
self.timer.start()
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.updateLabel)
|
||||
|
||||
self.updateLabel()
|
||||
self.showTooltip('')
|
||||
except Exception as (strerror):
|
||||
self.showTooltip(str(strerror))
|
||||
self.label.setText('<font color="red">ERROR</font>')
|
||||
return
|
||||
|
||||
def updateLabel(self):
|
||||
"""function to update label"""
|
||||
line = self.formating_line()
|
||||
text = "<html><head/><body style=\" font-family:\'" + self.font_family + "\'; font-size:" + str(self.font_size)
|
||||
text = text +"pt; font-style:" + self.font_style + ";\">"
|
||||
text = text + "<p align=\"center\"><span style=\" color:" + self.font_color + ";\"><pre>" + line
|
||||
text = text + "</pre></span></p></body></html>"
|
||||
self.label.setText(text)
|
||||
|
||||
def batText(self):
|
||||
"""function to set battery text"""
|
||||
commandOut = commands.getoutput("acpi")
|
||||
bat = commandOut.split()[3][:-1]
|
||||
output = "%3s" % (bat)
|
||||
|
||||
return output
|
||||
|
||||
def cpuText(self):
|
||||
"""function to set cpu text"""
|
||||
with open ("/proc/stat", 'r') as stat:
|
||||
for line in stat:
|
||||
if (line[0:4] == "cpu "):
|
||||
cpu_1 = line.split()[1:5]
|
||||
time.sleep(0.1)
|
||||
with open ("/proc/stat", 'r') as stat:
|
||||
for line in stat:
|
||||
if (line[0:4] == "cpu "):
|
||||
cpu_2 = line.split()[1:5]
|
||||
duser = float(cpu_2[0]) - float(cpu_1[0])
|
||||
dnice = float(cpu_2[1]) - float(cpu_1[1])
|
||||
dsys = float(cpu_2[2]) - float(cpu_1[2])
|
||||
didle = float(cpu_2[3]) - float(cpu_1[3])
|
||||
full = duser + dnice + dsys + didle
|
||||
cpu = (full-didle) / full * 100
|
||||
output = "%5s" % (str(round(cpu, 1)))
|
||||
|
||||
return output
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
line = commands.getoutput("free | grep Mem:")
|
||||
used = float(line.split()[2]) - float(line.split()[4]) - float(line.split()[5]) - float(line.split()[6])
|
||||
full = float(line.split()[1])
|
||||
mem = 100 * used / full
|
||||
output = "%5s" % (str(round(mem, 1)))
|
||||
|
||||
return output
|
||||
|
||||
def netText(self):
|
||||
"""function to set netspeed text"""
|
||||
if (self.num_dev == 0):
|
||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||
if (line != ''):
|
||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
||||
netdev = line.split()[0][:-1]
|
||||
else:
|
||||
interfaces = []
|
||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||
if (line != ''):
|
||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
||||
interfaces.append(line.split()[0][:-1])
|
||||
|
||||
command_line = "if ! (ifconfig "+ interfaces[1] + " | grep 'inet ' > /dev/null); then "
|
||||
command_line = command_line + "if ! (ifconfig "+ interfaces[0] + " | grep 'inet ' > /dev/null); then echo lo; "
|
||||
command_line = command_line + "else echo "+ interfaces[0] + "; fi; else echo "+ interfaces[1] + "; fi"
|
||||
netdev = commands.getoutput(command_line)
|
||||
|
||||
command_line = "RXB=$(cat /sys/class/net/" + netdev
|
||||
command_line = command_line + "/statistics/rx_bytes) && TXB=$(cat /sys/class/net/" + netdev
|
||||
command_line = command_line + "/statistics/tx_bytes) && sleep 0.1 && RXBN=$(cat /sys/class/net/" + netdev
|
||||
command_line = command_line + "/statistics/rx_bytes) && TXBN=$(cat /sys/class/net/" + netdev
|
||||
command_line = command_line + "/statistics/tx_bytes) && RXDIF=$(echo $((RXBN - RXB)) ) && TXDIF=$(echo $((TXBN - TXB)) ) "
|
||||
command_line = command_line + "&& echo -en $((10*RXDIF/1024/2)) && echo -n ' / ' && echo -en $((10*TXDIF/1024)) && echo ' KB/s'"
|
||||
speed = commands.getoutput(command_line)
|
||||
|
||||
downSpeed = speed.split()[0]
|
||||
upSpeed = speed.split()[2]
|
||||
output = "%4s/%4s" % (downSpeed, upSpeed)
|
||||
|
||||
return output
|
||||
|
||||
def swapText(self):
|
||||
"""function to set swap text"""
|
||||
line = commands.getoutput("free | grep Swap:")
|
||||
used = float(line.split()[2])
|
||||
full = float(line.split()[1])
|
||||
mem = 100 * used / full
|
||||
output = "%5s" % (str(round(mem, 1)))
|
||||
|
||||
return output
|
||||
|
||||
def tempText(self):
|
||||
"""function to set temp text"""
|
||||
commandOut = commands.getoutput("sensors | grep Physical")
|
||||
temp = commandOut[17:21]
|
||||
output = "%4s" % (temp)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
|
||||
def CreateApplet(parent):
|
||||
return pyTextWidget(parent)
|
@ -1,36 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from PyKDE4.kdecore import *
|
||||
|
||||
|
||||
|
||||
class Util():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
|
||||
def createDirectory(self, name):
|
||||
if not os.path.isdir(name):
|
||||
try:
|
||||
os.mkdir(name)
|
||||
except:
|
||||
print 'Failed to create directory: ' + name
|
||||
|
||||
def kdeHome(self):
|
||||
return unicode(KGlobal.dirs().localkdedir())
|
||||
|
||||
def createNotifyrc(self):
|
||||
print '[%s] creating notifyrc' % (self.applet._name)
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.notifyrc' % self.applet._name
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
||||
|
||||
def createConfig(self):
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.ini' % self.applet._name
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.ini' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
@ -1,710 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>302</width>
|
||||
<height>247</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>247</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>242</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget_format" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_format">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_format">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget_interval" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer02">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QWidget" name="widget_font" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_font">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer05">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="fontFilters">
|
||||
<set>QFontComboBox::AllFonts</set>
|
||||
</property>
|
||||
<property name="currentFont">
|
||||
<font>
|
||||
<family>Terminus</family>
|
||||
<pointsize>12</pointsize>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QWidget" name="widget_fontSize" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer01">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QWidget" name="widget_color" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer04">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QWidget" name="widget_style" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_style">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer06">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_style">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QWidget" name="widget_numNet" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numNet">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number of network devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer03">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_numNet">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>widget</zorder>
|
||||
<zorder>verticalSpacer</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_format</tabstop>
|
||||
<tabstop>spinBox_interval</tabstop>
|
||||
<tabstop>fontComboBox</tabstop>
|
||||
<tabstop>spinBox_fontSize</tabstop>
|
||||
<tabstop>kcolorcombo</tabstop>
|
||||
<tabstop>lineEdit_style</tabstop>
|
||||
<tabstop>comboBox_numNet</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,17 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Py Text Monitor
|
||||
Type=Service
|
||||
ServiceTypes=Plasma/Applet
|
||||
Icon=utilities-system-monitor
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=py-text-monitor
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
@ -1,16 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from util import *
|
||||
|
||||
|
||||
|
||||
class Config():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
self.config = self.applet.globalConfig()
|
||||
|
||||
def get(self, key, default = ''):
|
||||
return self.config.readEntry(key, default).toString()
|
||||
|
||||
def set(self, key, value):
|
||||
self.config.writeEntry(key, value)
|
@ -1,15 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
from PyKDE4 import plasmascript
|
||||
|
||||
|
||||
|
||||
class ConfigWindow(QWidget):
|
||||
def __init__(self, parent, settings):
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)
|
||||
self.parent = parent
|
@ -1,260 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
from PyKDE4.kio import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
from PyKDE4 import plasmascript
|
||||
from PyQt4 import QtCore
|
||||
from configwindow import *
|
||||
from config import *
|
||||
from util import *
|
||||
import commands, os, time
|
||||
|
||||
|
||||
|
||||
class pyTextWidget(plasmascript.Applet):
|
||||
def __init__(self,parent, args=None):
|
||||
"""widget definition"""
|
||||
plasmascript.Applet.__init__(self,parent)
|
||||
|
||||
def init(self):
|
||||
"""function to initializate widget"""
|
||||
self._name = str(self.package().metadata().pluginName())
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
self.setHasConfigurationInterface(True)
|
||||
|
||||
self.label = Plasma.Label(self.applet)
|
||||
self.label.setText("N\A")
|
||||
|
||||
self.layout.addItem(self.label)
|
||||
self.applet.setLayout(self.layout)
|
||||
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
|
||||
#initial configuration
|
||||
self.settings = Config(self)
|
||||
self.format = str(self.settings.get('format', '[cpu: $cpu%][temp: $temp°C][mem: $mem%][swap: $swap%][net: $netKB/s][bat: $bat%]'))
|
||||
self.interval = int(self.settings.get('interval', '2000'))
|
||||
self.font_family = str(self.settings.get('font_family', 'Terminus'))
|
||||
self.font_size = int(self.settings.get('font_size', 12))
|
||||
self.font_color = str(self.settings.get('font_color', '#000000'))
|
||||
self.font_style = str(self.settings.get('font_style', 'normal'))
|
||||
self.num_dev = int(self.settings.get('num_dev', 0))
|
||||
|
||||
self.setupNetdev()
|
||||
self.setupTemp()
|
||||
self.connectToEngine()
|
||||
|
||||
self.cpuText = " 0.0"
|
||||
self.up_speed = " 0"
|
||||
self.down_speed = " 0"
|
||||
self.mem_used = 0.0
|
||||
self.mem_free = 1.0
|
||||
self.mem_uf = 0.0
|
||||
self.swap_free = 1.0
|
||||
self.swap_used = 0.0
|
||||
self.tempText = " 0.0"
|
||||
|
||||
self.resize(250,10)
|
||||
|
||||
# start timer
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.setInterval(self.interval)
|
||||
self.startPolling()
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
# update local variables
|
||||
self.format = str(self.configpage.ui.lineEdit_format.text())
|
||||
self.interval = int(self.configpage.ui.spinBox_interval.value())
|
||||
self.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
|
||||
self.font_size = int(self.configpage.ui.spinBox_fontSize.value())
|
||||
self.font_color = str(self.configpage.ui.kcolorcombo.color().name())
|
||||
self.font_style = str(self.configpage.ui.lineEdit_style.text())
|
||||
self.num_dev = int(self.configpage.ui.comboBox_numNet.currentIndex())
|
||||
|
||||
# save config to settings
|
||||
self.settings.set('format', self.format)
|
||||
self.settings.set('interval', self.interval)
|
||||
self.settings.set('font_family', self.font_family)
|
||||
self.settings.set('font_size', self.font_size)
|
||||
self.settings.set('font_color', self.font_color)
|
||||
self.settings.set('font_style', self.font_style)
|
||||
self.settings.set('num_dev', self.num_dev)
|
||||
|
||||
# update timer
|
||||
self.timer.setInterval(self.interval)
|
||||
self.startPolling()
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
self.configpage = ConfigWindow(self, self.settings)
|
||||
|
||||
font = QFont(str(self.settings.get('font_family', 'Terminus')), int(self.settings.get('font_size', 12)), int(int(self.settings.get('font_weight', 50))))
|
||||
self.configpage.ui.lineEdit_format.setText(str(self.settings.get('format', '[cpu: $cpu%][temp: $temp°C][mem: $mem%][swap: $swap%][net: $netKB/s][bat: $bat%]')))
|
||||
self.configpage.ui.spinBox_interval.setValue(int(self.settings.get('interval', '2000')))
|
||||
self.configpage.ui.fontComboBox.setCurrentFont(font)
|
||||
self.configpage.ui.spinBox_fontSize.setValue(int(self.settings.get('font_size', 12)))
|
||||
self.configpage.ui.kcolorcombo.setColor(QColor(str(self.settings.get('font_color', '#000000'))))
|
||||
self.configpage.ui.lineEdit_style.setText(str(self.settings.get('font_style', 'normal')))
|
||||
self.configpage.ui.comboBox_numNet.setCurrentIndex(int(self.settings.get('num_dev', 0)))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.name()))
|
||||
page.setIcon(KIcon(self.icon()))
|
||||
|
||||
parent.okClicked.connect(self.configAccepted)
|
||||
|
||||
def formating_line(self):
|
||||
"""function to set format line"""
|
||||
output = self.format
|
||||
|
||||
if (output.split("$cpu")[0] != output):
|
||||
output = output.split("$cpu")[0] + self.cpuText + output.split("$cpu")[1]
|
||||
if (output.split("$temp")[0] != output):
|
||||
output = output.split("$temp")[0] + self.tempText + output.split("$temp")[1]
|
||||
if (output.split("$mem")[0] != output):
|
||||
output = output.split("$mem")[0] + self.memText() + output.split("$mem")[1]
|
||||
if (output.split("$swap")[0] != output):
|
||||
output = output.split("$swap")[0] + self.swapText() + output.split("$swap")[1]
|
||||
if (output.split("$net")[0] != output):
|
||||
output = output.split("$net")[0] + self.netText() + output.split("$net")[1]
|
||||
if (output.split("$bat")[0] != output):
|
||||
output = output.split("$bat")[0] + self.batText() + output.split("$bat")[1]
|
||||
|
||||
return output
|
||||
|
||||
def setupNetdev(self):
|
||||
if (self.num_dev == 0):
|
||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||
if (line != ''):
|
||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
||||
self.netdev = line.split()[0][:-1]
|
||||
else:
|
||||
interfaces = []
|
||||
for line in commands.getoutput("ifconfig -a").split("\n"):
|
||||
if (line != ''):
|
||||
if ((line[0] != ' ') and (line[0:3] != "lo:")):
|
||||
interfaces.append(line.split()[0][:-1])
|
||||
|
||||
command_line = "if ! (ifconfig "+ interfaces[1] + " | grep 'inet ' > /dev/null); then "
|
||||
command_line = command_line + "if ! (ifconfig "+ interfaces[0] + " | grep 'inet ' > /dev/null); then echo lo; "
|
||||
command_line = command_line + "else echo "+ interfaces[0] + "; fi; else echo "+ interfaces[1] + "; fi"
|
||||
self.netdev = commands.getoutput(command_line)
|
||||
|
||||
def setupTemp(self):
|
||||
commandOut = commands.getoutput("sensors | grep Physical -B2")
|
||||
self.tempdev = "lmsensors/"+commandOut.split("\n")[0]+"/"+'_'.join(commandOut.split("\n")[2].split(":")[0].split())
|
||||
|
||||
def showConfigurationInterface(self):
|
||||
"""function to show configuration window"""
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
|
||||
def showTooltip(self, text):
|
||||
"""function to create and set tooltip"""
|
||||
tooltip = Plasma.ToolTipContent()
|
||||
tooltip.setImage(KIcon(self.icon()))
|
||||
tooltip.setSubText(text)
|
||||
tooltip.setAutohide(False)
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, tooltip)
|
||||
Plasma.ToolTipManager.self().registerWidget(self.applet)
|
||||
|
||||
def startPolling(self):
|
||||
try:
|
||||
self.timer.start()
|
||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.updateLabel)
|
||||
|
||||
self.updateLabel()
|
||||
self.showTooltip('')
|
||||
except Exception as (strerror):
|
||||
self.showTooltip(str(strerror))
|
||||
self.label.setText('<font color="red">ERROR</font>')
|
||||
return
|
||||
|
||||
def updateLabel(self):
|
||||
"""function to update label"""
|
||||
string = self.formating_line()
|
||||
text = "<html><head/><body style=\" font-family:\'"+ self.font_family +"\'; font-size:"+ str(self.font_size)
|
||||
text = text +"pt; font-style:"+ self.font_style +";\">"
|
||||
text = text + "<p align=\"center\"><span style=\" color:" + self.font_color + ";\"><pre>"+string
|
||||
text = text + "</pre></span></p></body></html>"
|
||||
self.label.setText(text)
|
||||
|
||||
def batText(self):
|
||||
"""function to set battery text"""
|
||||
commandOut = commands.getoutput("acpi")
|
||||
bat = commandOut.split()[3][:-1]
|
||||
output = "%3s" % (bat)
|
||||
|
||||
return output
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
full = self.mem_uf + self.mem_free
|
||||
mem = 100 * self.mem_used / full
|
||||
output = "%5s" % (str(round(mem, 1)))
|
||||
|
||||
return output
|
||||
|
||||
def netText(self):
|
||||
"""function to set netspeed text"""
|
||||
output = self.down_speed + "/" + self.up_speed
|
||||
|
||||
return output
|
||||
|
||||
def swapText(self):
|
||||
"""function to set swap text"""
|
||||
full = self.swap_used + self.swap_free
|
||||
mem = 100 * self.swap_used / full
|
||||
output = "%5s" % (str(round(mem, 1)))
|
||||
|
||||
return output
|
||||
|
||||
def connectToEngine(self):
|
||||
"""function to initializate engine"""
|
||||
self.systemmonitor = self.dataEngine("systemmonitor")
|
||||
self.systemmonitor.connectSource("cpu/system/TotalLoad", self, 200)
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/transmitter/data", self, 200)
|
||||
self.systemmonitor.connectSource("network/interfaces/"+self.netdev+"/receiver/data", self, 200)
|
||||
self.systemmonitor.connectSource(self.tempdev, self, 200)
|
||||
self.systemmonitor.connectSource("mem/physical/free", self, 200)
|
||||
self.systemmonitor.connectSource("mem/physical/used", self, 200)
|
||||
self.systemmonitor.connectSource("mem/physical/application", self, 200)
|
||||
self.systemmonitor.connectSource("mem/swap/free", self, 200)
|
||||
self.systemmonitor.connectSource("mem/swap/used", self, 200)
|
||||
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to refresh data"""
|
||||
if (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
self.cpuText = "%5s" % (value)
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
self.up_speed = "%4s" % (value)
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/reciever/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
self.down_speed = "%4s" % (value)
|
||||
elif (sourceName == self.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
self.tempText = "%4s" % (value)
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
self.mem_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
self.mem_uf = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
self.mem_used = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
self.swap_free = float(data[QString(u'value')])
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
self.swap_used = float(data[QString(u'value')])
|
||||
|
||||
|
||||
|
||||
def CreateApplet(parent):
|
||||
return pyTextWidget(parent)
|
@ -1,36 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from PyKDE4.kdecore import *
|
||||
|
||||
|
||||
|
||||
class Util():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
|
||||
def createDirectory(self, name):
|
||||
if not os.path.isdir(name):
|
||||
try:
|
||||
os.mkdir(name)
|
||||
except:
|
||||
print 'Failed to create directory: ' + name
|
||||
|
||||
def kdeHome(self):
|
||||
return unicode(KGlobal.dirs().localkdedir())
|
||||
|
||||
def createNotifyrc(self):
|
||||
print '[%s] creating notifyrc' % (self.applet._name)
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.notifyrc' % self.applet._name
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
||||
|
||||
def createConfig(self):
|
||||
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
|
||||
|
||||
source = self.applet.package().path() + 'contents/misc/%s.ini' % self.applet._name
|
||||
destination = self.kdeHome() + 'share/apps/%s/%s.ini' % (self.applet._name, self.applet._name)
|
||||
copyfile(source, destination)
|
@ -1,710 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>302</width>
|
||||
<height>247</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>247</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>242</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="widget_format" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_format">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_format">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget_interval" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer02">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QWidget" name="widget_font" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_font">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer05">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="fontFilters">
|
||||
<set>QFontComboBox::AllFonts</set>
|
||||
</property>
|
||||
<property name="currentFont">
|
||||
<font>
|
||||
<family>Terminus</family>
|
||||
<pointsize>12</pointsize>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QWidget" name="widget_fontSize" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer01">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QWidget" name="widget_color" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer04">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QWidget" name="widget_style" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_style">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer06">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_style">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QWidget" name="widget_numNet" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numNet">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number of network devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer03">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_numNet">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>widget</zorder>
|
||||
<zorder>verticalSpacer</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_format</tabstop>
|
||||
<tabstop>spinBox_interval</tabstop>
|
||||
<tabstop>fontComboBox</tabstop>
|
||||
<tabstop>spinBox_fontSize</tabstop>
|
||||
<tabstop>kcolorcombo</tabstop>
|
||||
<tabstop>lineEdit_style</tabstop>
|
||||
<tabstop>comboBox_numNet</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,17 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Py Text Monitor
|
||||
Type=Service
|
||||
ServiceTypes=Plasma/Applet
|
||||
Icon=utilities-system-monitor
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=py-text-monitor
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
BIN
old_versions/pytextmonitor-0.9.plasmoid
Normal file
BIN
old_versions/pytextmonitor-0.9.plasmoid
Normal file
Binary file not shown.
BIN
old_versions/pytextmonitor-1.1.1.plasmoid
Normal file
BIN
old_versions/pytextmonitor-1.1.1.plasmoid
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 144 KiB |
@ -36,10 +36,14 @@ class ConfigWindow(QWidget):
|
||||
if (self.ui.checkBox_bat.checkState() == 2):
|
||||
self.ui.lineEdit_bat.setEnabled(True)
|
||||
self.ui.slider_bat.setEnabled(True)
|
||||
self.ui.lineEdit_acdev.setEnabled(True)
|
||||
self.ui.lineEdit_batdev.setEnabled(True)
|
||||
self.setSlider()
|
||||
else:
|
||||
self.ui.lineEdit_bat.setDisabled(True)
|
||||
self.ui.slider_bat.setDisabled(True)
|
||||
self.ui.lineEdit_acdev.setDisabled(True)
|
||||
self.ui.lineEdit_batdev.setDisabled(True)
|
||||
self.setSlider()
|
||||
|
||||
def cpuStatus(self):
|
||||
@ -323,4 +327,4 @@ class ConfigWindow(QWidget):
|
||||
|
||||
for value in range(count+1)[1:]:
|
||||
if (oldOrder.find(str(value)) == -1):
|
||||
return int(value)
|
||||
return int(value)
|
||||
|
@ -153,8 +153,12 @@ class pyTextWidget(plasmascript.Applet):
|
||||
else:
|
||||
self.batBool = 0
|
||||
self.batFormat = str(self.configpage.ui.lineEdit_bat.text())
|
||||
self.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
|
||||
self.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
|
||||
self.settings.set('batBool', self.batBool)
|
||||
self.settings.set('batFormat', self.batFormat)
|
||||
self.settings.set('battery_device', self.battery_device)
|
||||
self.settings.set('ac_device', self.ac_device)
|
||||
|
||||
self.label_order = ''.join(self.label_order.split('-'))
|
||||
self.settings.set('label_order', self.label_order)
|
||||
@ -259,11 +263,17 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.configpage.ui.slider_bat.setValue(self.label_order.find("6")+1)
|
||||
self.configpage.ui.slider_bat.setEnabled(True)
|
||||
self.configpage.ui.lineEdit_bat.setEnabled(True)
|
||||
self.configpage.ui.lineEdit_acdev.setEnabled(True)
|
||||
self.configpage.ui.lineEdit_batdev.setEnabled(True)
|
||||
else:
|
||||
self.configpage.ui.checkBox_bat.setCheckState(0)
|
||||
self.configpage.ui.slider_bat.setDisabled(True)
|
||||
self.configpage.ui.lineEdit_bat.setDisabled(True)
|
||||
self.configpage.ui.lineEdit_bat.setText(str(self.settings.get('batFormat', '[bat: $bat%]')))
|
||||
self.configpage.ui.lineEdit_acdev.setDisabled(True)
|
||||
self.configpage.ui.lineEdit_batdev.setDisabled(True)
|
||||
self.configpage.ui.lineEdit_bat.setText(str(self.settings.get('batFormat', '[bat: $bat%$ac]')))
|
||||
self.configpage.ui.lineEdit_batdev.setText(str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
|
||||
self.configpage.ui.lineEdit_acdev.setText(str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online')))
|
||||
|
||||
# add config page
|
||||
page = parent.addPage(self.configpage, i18n(self.name()))
|
||||
@ -315,7 +325,11 @@ class pyTextWidget(plasmascript.Applet):
|
||||
if (self.cpuBool == 1):
|
||||
self.cpuFormat = str(self.settings.get('cpuFormat', '[cpu: $cpu%]'))
|
||||
self.label_cpu = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + self.cpuFormat.split('$cpu')[0] + '-----' + self.cpuFormat.split('$cpu')[1] + self.formatLine.split('$LINE')[1]
|
||||
if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat):
|
||||
line = self.cpuFormat.split('$cpu')[0] + '-----' + self.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu.setText(text)
|
||||
self.layout.addItem(self.label_cpu)
|
||||
elif (order == "2"):
|
||||
@ -323,7 +337,11 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.tempFormat = str(self.settings.get('tempFormat', '[temp: $temp°C]'))
|
||||
self.setupTemp()
|
||||
self.label_temp = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + self.tempFormat.split('$temp')[0] + '----' + self.tempFormat.split('$temp')[1] + self.formatLine.split('$LINE')[1]
|
||||
if (self.tempFormat.split('$temp')[0] != self.tempFormat):
|
||||
line = self.tempFormat.split('$temp')[0] + '----' + self.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.tempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_temp.setText(text)
|
||||
self.layout.addItem(self.label_temp)
|
||||
elif (order == "3"):
|
||||
@ -337,7 +355,11 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.mem_used = 0.0
|
||||
self.mem_free = 1.0
|
||||
self.mem_uf = 0.0
|
||||
text = self.formatLine.split('$LINE')[0] + self.memFormat.split('$mem')[0] + '-----' + self.memFormat.split('$mem')[1] + self.formatLine.split('$LINE')[1]
|
||||
if (self.memFormat.split('$mem')[0] != self.memFormat):
|
||||
line = self.memFormat.split('$mem')[0] + '-----' + self.memFormat.split('$mem')[1]
|
||||
else:
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem = Plasma.Label(self.applet)
|
||||
self.label_mem.setText(text)
|
||||
self.layout.addItem(self.label_mem)
|
||||
@ -349,9 +371,13 @@ class pyTextWidget(plasmascript.Applet):
|
||||
text = self.formatLine.split('$LINE')[0] + self.swapFormat.split('$swapmb')[0] + '-----' + self.swapFormat.split('$swapmb')[1] + self.formatLine.split('$LINE')[1]
|
||||
else:
|
||||
self.swapInMb = False
|
||||
text = self.formatLine.split('$LINE')[0] + self.swapFormat.split('$swap')[0] + '-----' + self.swapFormat.split('$swap')[1] + self.formatLine.split('$LINE')[1]
|
||||
self.swap_free = 1.0
|
||||
self.swap_used = 0.0
|
||||
if (self.swapFormat.split('$swap')[0] != self.swapFormat):
|
||||
line = self.swapFormat.split('$swap')[0] + '-----' + self.swapFormat.split('$swap')[1]
|
||||
else:
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap = Plasma.Label(self.applet)
|
||||
self.label_swap.setText(text)
|
||||
self.layout.addItem(self.label_swap)
|
||||
@ -369,25 +395,44 @@ class pyTextWidget(plasmascript.Applet):
|
||||
else:
|
||||
self.netFormat = self.netNonFormat
|
||||
self.label_netDown = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + self.netFormat.split('$net')[0] + '----' + self.formatLine.split('$LINE')[1]
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = self.netFormat.split('$net')[0] + '----'
|
||||
else:
|
||||
line = self.netFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netDown.setText(text)
|
||||
self.layout.addItem(self.label_netDown)
|
||||
self.label_netUp = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + '/----' + self.netFormat.split('$net')[1] + self.formatLine.split('$LINE')[1]
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = '/----' + self.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netUp.setText(text)
|
||||
self.layout.addItem(self.label_netUp)
|
||||
elif (order == "6"):
|
||||
if (self.batBool == 1):
|
||||
self.batFormat = str(self.settings.get('batFormat', '[bat: $bat%]'))
|
||||
self.batFormat = str(self.settings.get('batFormat', '[bat: $bat%$ac]'))
|
||||
self.battery_device= str(self.settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
self.ac_device = str(self.settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
self.label_bat = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + self.batFormat.split('$bat')[0] + '---' + self.batFormat.split('$bat')[1] + self.formatLine.split('$LINE')[1]
|
||||
line = self.batFormat
|
||||
if (line.split('$ac')[0] != line):
|
||||
line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1]
|
||||
if (line.split('$bat')[0] != line):
|
||||
line = line.split('$bat')[0] + '---' + line.split('$bat')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_bat.setText(text)
|
||||
self.layout.addItem(self.label_bat)
|
||||
elif (order == "7"):
|
||||
if (self.cpuclockBool == 1):
|
||||
self.cpuclockFormat = str(self.settings.get('cpuclockFormat', '[MHz: $cpucl]'))
|
||||
self.label_cpuclock = Plasma.Label(self.applet)
|
||||
text = self.formatLine.split('$LINE')[0] + self.cpuclockFormat.split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$cpucl')[1] + self.formatLine.split('$LINE')[1]
|
||||
if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat):
|
||||
line = self.cpuclockFormat.split('$cpucl')[0] + '----' + self.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock.setText(text)
|
||||
self.layout.addItem(self.label_cpuclock)
|
||||
self.applet.setLayout(self.layout)
|
||||
@ -464,9 +509,20 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def batText(self):
|
||||
"""function to set battery text"""
|
||||
commandOut = commands.getoutput("acpi")
|
||||
bat = "%3s" % (commandOut.split(':')[1].split()[1].split('%')[0])
|
||||
line = self.batFormat.split('$bat')[0] + bat + self.batFormat.split('$bat')[1]
|
||||
line = self.batFormat
|
||||
if (line.split('$bat')[0] != line):
|
||||
with open (self.battery_device, 'r') as bat_file:
|
||||
bat = bat_file.readline().split('\n')[0]
|
||||
bat = "%3s" % (bat)
|
||||
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
|
||||
if (line.split('$ac')[0] != line):
|
||||
with open (self.ac_device, 'r') as bat_file:
|
||||
bat = bat_file.readline().split('\n')[0]
|
||||
if (bat == '1'):
|
||||
bat = '(*)'
|
||||
else:
|
||||
bat = '( )'
|
||||
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_bat.setText(text)
|
||||
|
||||
@ -475,7 +531,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
full = self.mem_uf + self.mem_free
|
||||
mem = 100 * self.mem_used / full
|
||||
mem = "%5s" % (str(round(mem, 1)))
|
||||
line = self.memFormat.split('$mem')[0] + mem + self.memFormat.split('$mem')[1]
|
||||
if (self.memFormat.split('$mem')[0] != self.memFormat):
|
||||
line = self.memFormat.split('$mem')[0] + mem + self.memFormat.split('$mem')[1]
|
||||
else:
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem.setText(text)
|
||||
|
||||
@ -484,7 +543,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
full = self.swap_used + self.swap_free
|
||||
mem = 100 * self.swap_used / full
|
||||
mem = "%5s" % (str(round(mem, 1)))
|
||||
line = self.swapFormat.split('$swap')[0] + mem + self.swapFormat.split('$swap')[1]
|
||||
if (self.swapFormat.split('$swap')[0] != self.swapFormat):
|
||||
line = self.swapFormat.split('$swap')[0] + mem + self.swapFormat.split('$swap')[1]
|
||||
else:
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap.setText(text)
|
||||
|
||||
@ -521,25 +583,37 @@ class pyTextWidget(plasmascript.Applet):
|
||||
if (sourceName == "cpu/system/TotalLoad"):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
cpuText = "%5s" % (value)
|
||||
line = self.cpuFormat.split('$cpu')[0] + cpuText + self.cpuFormat.split('$cpu')[1]
|
||||
if (self.cpuFormat.split('$cpu')[0] != self.cpuFormat):
|
||||
line = self.cpuFormat.split('$cpu')[0] + cpuText + self.cpuFormat.split('$cpu')[1]
|
||||
else:
|
||||
line = self.cpuFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpu.setText(text)
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
cpuclockText = "%4s" % (value)
|
||||
line = self.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$cpucl')[1]
|
||||
if (self.cpuclockFormat.split('$cpucl')[0] != self.cpuclockFormat):
|
||||
line = self.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.cpuclockFormat.split('$cpucl')[1]
|
||||
else:
|
||||
line = self.cpuclockFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_cpuclock.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/transmitter/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
up_speed = "%4s" % (value)
|
||||
line = '/' + up_speed + self.netFormat.split('$net')[1]
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = '/' + up_speed + self.netFormat.split('$net')[1]
|
||||
else:
|
||||
line = ''
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netUp.setText(text)
|
||||
elif (sourceName == "network/interfaces/"+self.netdev+"/receiver/data"):
|
||||
value = str(data[QString(u'value')]).split('.')[0]
|
||||
down_speed = "%4s" % (value)
|
||||
line = self.netFormat.split('$net')[0] + down_speed
|
||||
if (self.netFormat.split('$net')[0] != self.netFormat):
|
||||
line = self.netFormat.split('$net')[0] + down_speed
|
||||
else:
|
||||
line = self.netFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_netDown.setText(text)
|
||||
# update network device
|
||||
@ -559,7 +633,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
elif (sourceName == self.tempdev):
|
||||
value = str(round(float(data[QString(u'value')]), 1))
|
||||
tempText = "%4s" % (value)
|
||||
line = self.tempFormat.split('$temp')[0] + tempText + self.tempFormat.split('$temp')[1]
|
||||
if (self.tempFormat.split('$temp')[0] != self.tempFormat):
|
||||
line = self.tempFormat.split('$temp')[0] + tempText + self.tempFormat.split('$temp')[1]
|
||||
else:
|
||||
line = self.tempFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_temp.setText(text)
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
@ -570,7 +647,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
if (self.memInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
line = self.memFormat.split('$memmb')[0] + mem + self.memFormat.split('$memmb')[1]
|
||||
if (self.memFormat.split('$memmb')[0] != self.memFormat):
|
||||
line = self.memFormat.split('$memmb')[0] + mem + self.memFormat.split('$memmb')[1]
|
||||
else:
|
||||
line = self.memFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_mem.setText(text)
|
||||
else:
|
||||
@ -581,7 +661,10 @@ class pyTextWidget(plasmascript.Applet):
|
||||
if (self.swapInMb):
|
||||
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
|
||||
mem = "%5s" % (mem)
|
||||
line = self.swapFormat.split('$swapmb')[0] + mem + self.swapFormat.split('$swapmb')[1]
|
||||
if (self.swapFormat.split('$swapmb')[0] != self.swapFormat):
|
||||
line = self.swapFormat.split('$swapmb')[0] + mem + self.swapFormat.split('$swapmb')[1]
|
||||
else:
|
||||
line = self.swapFormat
|
||||
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
|
||||
self.label_swap.setText(text)
|
||||
else:
|
||||
@ -590,4 +673,4 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
|
||||
def CreateApplet(parent):
|
||||
return pyTextWidget(parent)
|
||||
return pyTextWidget(parent)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>455</height>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -19,7 +19,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>519</width>
|
||||
<height>455</height>
|
||||
<height>519</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
@ -43,13 +43,13 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>511</width>
|
||||
<height>450</height>
|
||||
<height>508</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>450</height>
|
||||
<height>508</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -847,6 +847,152 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="batdev">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_null01">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>111</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>111</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_batdev">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Battery device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_batdev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="acdev">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_null02">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>111</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>111</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_acdev">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">AC device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_acdev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_interval" native="true">
|
||||
<property name="sizePolicy">
|
||||
@ -1421,6 +1567,8 @@
|
||||
<zorder>widget_bat</zorder>
|
||||
<zorder>widget_cpuclock</zorder>
|
||||
<zorder>widget_weight</zorder>
|
||||
<zorder>horizontalLayoutWidget</zorder>
|
||||
<zorder>horizontalLayoutWidget_2</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
@ -1470,6 +1618,8 @@
|
||||
<tabstop>checkBox_bat</tabstop>
|
||||
<tabstop>lineEdit_bat</tabstop>
|
||||
<tabstop>slider_bat</tabstop>
|
||||
<tabstop>lineEdit_batdev</tabstop>
|
||||
<tabstop>lineEdit_acdev</tabstop>
|
||||
<tabstop>spinBox_interval</tabstop>
|
||||
<tabstop>fontComboBox</tabstop>
|
||||
<tabstop>spinBox_fontSize</tabstop>
|
||||
|
@ -9,7 +9,7 @@ X-Plasma-MainScript=code/main.py
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alexeev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=py-text-monitor
|
||||
X-KDE-PluginInfo-Version=1.1.4
|
||||
X-KDE-PluginInfo-Version=1.2.0
|
||||
X-KDE-PluginInfo-Website=http://kde-look.org/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
|
Loading…
Reference in New Issue
Block a user