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
?
Asked
Active
Viewed 5,756 times
11

rohitnambisan99
- 121
- 2
- 6
2 Answers
25
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.

Honest Abe
- 8,430
- 4
- 49
- 64

alvaropg
- 496
- 5
- 9
-
1And you can read some useful tips in https://wiki.gnome.org/HowDoI/GNotification (in C, but easy to use in Python thanks to the introspection) – alvaropg Apr 14 '14 at 09:00
-
i have tried this before and it gives notifications similiar to network or sound notifications. Is there any way to give it on the message tray at the top? – rohitnambisan99 Apr 14 '14 at 09:15
-
AFAIK the top bar in GNOME-Shell hasn't any message tray as in GNOME 2. But you can take a look a the Shell extensions https://extensions.gnome.org/ – alvaropg Apr 14 '14 at 10:13
-
Anyway, with this code the notification stay in the notifications area (bottom) until the user wants (doesn't works for you?) – alvaropg Apr 14 '14 at 10:16
-
It need not be message tray, is there any other way in GNOME to give notifications on the top panel in the screen?? And this code does work in my system. – rohitnambisan99 Apr 14 '14 at 15:07
-
AFAIK not by default, but take a look at this extension: https://extensions.gnome.org/extension/495/topicons/ – alvaropg Apr 22 '14 at 09:18
-
But looks that you want to do a shell extension: https://wiki.gnome.org/Projects/GnomeShell/Extensions – alvaropg Apr 22 '14 at 09:19