mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
Added notification for uptime
This commit is contained in:
parent
c729d6573d
commit
3994652562
1
TODO
1
TODO
@ -1,5 +1,4 @@
|
|||||||
1. Notification on left click (system information):
|
1. Notification on left click (system information):
|
||||||
a) uptime - uptime, kernel information
|
|
||||||
b) cpu, cpuclock, temp - cpu, cpuclock, temp, processor information
|
b) cpu, cpuclock, temp - cpu, cpuclock, temp, processor information
|
||||||
c) gpu, gputemp - gpu, gpu temp, gpu information
|
c) gpu, gputemp - gpu, gpu temp, gpu information
|
||||||
d) memory, swap - memory, swap, memory information
|
d) memory, swap - memory, swap, memory information
|
||||||
|
34
sources/contents/code/plasma_applet_pytextmonitor.notifyrc
Normal file
34
sources/contents/code/plasma_applet_pytextmonitor.notifyrc
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[Global]
|
||||||
|
IconName=system
|
||||||
|
Name=PyTextMonitor
|
||||||
|
Comment=PyTextMonitor information
|
||||||
|
|
||||||
|
[Event/system]
|
||||||
|
Name=System information
|
||||||
|
Comment=System information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/processor]
|
||||||
|
Name=Processor information
|
||||||
|
Comment=Processor information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/memory]
|
||||||
|
Name=Memory information
|
||||||
|
Comment=Memory information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/disk]
|
||||||
|
Name=Disk information
|
||||||
|
Comment=Disk information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/network]
|
||||||
|
Name=Network information
|
||||||
|
Comment=Network information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/battery]
|
||||||
|
Name=Battery information
|
||||||
|
Comment=Battery information
|
||||||
|
Action=Popup
|
@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from gi.repository import Notify
|
from PyKDE4.kdecore import KComponentData
|
||||||
|
from PyKDE4.kdeui import KNotification
|
||||||
|
import commands
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -10,11 +12,29 @@ class PTMNotify:
|
|||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
|
||||||
def exampleNotify(self):
|
def init(self):
|
||||||
Notify.init ("Hello world")
|
"""function to init notification"""
|
||||||
Hello=Notify.Notification.new ("Hello world","This is an example notification.","dialog-information")
|
content = self.initText(self.parent)
|
||||||
Hello.show ()
|
self.createNotify(content)
|
||||||
|
|
||||||
def createNotification(self):
|
|
||||||
|
def createNotify(self, content):
|
||||||
"""function to create notification for label"""
|
"""function to create notification for label"""
|
||||||
|
notification = KNotification(content[0])
|
||||||
|
notification.setComponentData(KComponentData("plasma_applet_pytextmonitor"))
|
||||||
|
notification.setTitle("PyTextMonitor info ::: " + content[0]);
|
||||||
|
notification.setText(content[1]);
|
||||||
|
notification.sendEvent();
|
||||||
|
|
||||||
|
|
||||||
|
def initText(self, sender):
|
||||||
|
"""function to create text"""
|
||||||
|
content = []
|
||||||
|
if (sender == self.parent.parent.label_uptime):
|
||||||
|
content.append("system")
|
||||||
|
text = "Kernel: " + commands.getoutput("uname -rsm") + "\n"
|
||||||
|
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
|
||||||
|
text = text + "Whoami: " + commands.getoutput("whoami") + "\n"
|
||||||
|
text = text + "Uptime: " + commands.getoutput("uptime")
|
||||||
|
content.append(text)
|
||||||
|
return content
|
||||||
|
@ -4,6 +4,22 @@ from PyQt4.QtCore import *
|
|||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyKDE4.plasma import Plasma
|
from PyKDE4.plasma import Plasma
|
||||||
import config
|
import config
|
||||||
|
import ptmnotify
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class NewPlasmaLabel(Plasma.Label):
|
||||||
|
"""new Label with defined clicked() event"""
|
||||||
|
def __init__(self, applet, parent):
|
||||||
|
"""class definition"""
|
||||||
|
Plasma.Label.__init__(self, applet)
|
||||||
|
self.parent = parent
|
||||||
|
self.notify = ptmnotify.PTMNotify(self)
|
||||||
|
|
||||||
|
|
||||||
|
def mousePressEvent(self, event):
|
||||||
|
"""mouse click event"""
|
||||||
|
self.notify.init()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -12,6 +28,7 @@ class Reinit():
|
|||||||
"""class definition"""
|
"""class definition"""
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
|
||||||
def reinit(self, confAccept=False):
|
def reinit(self, confAccept=False):
|
||||||
"""function to reinitializate widget"""
|
"""function to reinitializate widget"""
|
||||||
settings = config.Config(self.parent)
|
settings = config.Config(self.parent)
|
||||||
@ -192,7 +209,7 @@ class Reinit():
|
|||||||
elif (order == "8"):
|
elif (order == "8"):
|
||||||
if (self.parent.uptimeBool > 0):
|
if (self.parent.uptimeBool > 0):
|
||||||
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
|
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
|
||||||
self.parent.label_uptime = Plasma.Label(self.parent.applet)
|
self.parent.label_uptime = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
||||||
line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1]
|
line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user