Display notifications in Gnome Shell
Asked Answered
A

2

12

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?

Aurelioaurelius answered 12/4, 2014 at 14:23 Comment(0)
N
27

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.

Neptunian answered 14/4, 2014 at 8:58 Comment(7)
And you can read some useful tips in wiki.gnome.org/HowDoI/GNotification (in C, but easy to use in Python thanks to the introspection)Neptunian
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?Aurelioaurelius
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 extensions.gnome.orgNeptunian
Anyway, with this code the notification stay in the notifications area (bottom) until the user wants (doesn't works for you?)Neptunian
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.Aurelioaurelius
AFAIK not by default, but take a look at this extension: extensions.gnome.org/extension/495/topiconsNeptunian
But looks that you want to do a shell extension: wiki.gnome.org/Projects/GnomeShell/ExtensionsNeptunian
T
-3

In GNOME 3 the message tray is located at the bottom and nowhere else. Look at this extension in order to change the position notifications appear in.

Tiptoe answered 25/5, 2014 at 21:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.