Added notification for uptime

This commit is contained in:
arcan1s
2013-10-04 02:07:05 +04:00
parent c729d6573d
commit 3994652562
4 changed files with 80 additions and 10 deletions

View File

@ -1,6 +1,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
def exampleNotify(self):
Notify.init ("Hello world")
Hello=Notify.Notification.new ("Hello world","This is an example notification.","dialog-information")
Hello.show ()
def init(self):
"""function to init notification"""
content = self.initText(self.parent)
self.createNotify(content)
def createNotification(self):
def createNotify(self, content):
"""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