Sunday 23 September 2012

Create custom notification on your Ubuntu desktop using python

You can easily create custom notifications for your applications on ubuntu. Ubuntu's current notification system is called NotifyOSD. It provides api for several languages. Using python-notify library it is really so easy than in any other.

Ubuntu by default have the python-notify installed. If don't install it using

1
sudo apt-get install python-notify

Sample notification program using python for notifyOSD

Now you open gedit or any other text editor, paste the following code and save it as notify.py


#!/usr/bin/python
import sys
import pynotify
 if __name__ == "__main__":
    if not pynotify.init("icon-summary-body"):
        sys.exit(1)
 
    n = pynotify.Notification(
        "Burhan Uddin",
        "What is life? Full of of care? We have no time to stand or stare!",
        "notification-message-im")
    n.show()

Now run this py file using terminal

1
python notify.py

And see the output ..




No comments:

Post a Comment

Thanks for Visiting LinuxWorkstation