Persistent Notification in Gnome 3

August 15th, 2020 – 11:18 am
Categorized as Computing Notes
Tagged as ,

This is a GTK notification in Linux that remains on screen until it is clicked.

#!/usr/bin/python3

import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
gi.require_version('Gtk', '3.0')

Notify.init("Hello world")
Hello = Notify.Notification.new("Hello world - the heading",
                                "This is an example notification.",
                                "dialog-information")

# https://www.devdungeon.com/content/desktop-notifications-linux-python
Hello.set_urgency(2) # Highest priority
Hello.show()

Last updated and tested 12 December 2020 on CentOS 8 (not Stream).