Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display notifications in Gnome Shell

How can i send notifications in GNOME through a python program? I have tried python bindings like pynotify,python-notify2, but the all give pop-up notifications which are temporary. Is there any python bindings to give notifications on the message tray in GNOME?

like image 857
rohitnambisan99 Avatar asked Apr 12 '14 14:04

rohitnambisan99


1 Answers

You must use PyGObject, which gives you access to the GNOME platform through the use of GObject introspection. You can read an example in the Arch documentation for Desktop notifications:

from gi.repository import Notify
Notify.init ("Hello world")
Hello=Notify.Notification.new ("Hello world",
                               "This is an example notification.",
                               "dialog-information")
# Hello.set_timeout(0)
Hello.show ()

A timeout value of 0 makes it persistent (until the mouse is moved). For more information check out the PyGObject API Reference.

like image 134
alvaropg Avatar answered Oct 02 '22 19:10

alvaropg