Search code examples
pythongtkpygtkgnomenotify

Missing image/icon in GNOME's desktop notification


I'm trying to display a simple GNOME desktop notification through a Python script. According to GNOME's specification it's possible to display an image with the notification through a simple file URI (file://), but it just refuses to show it in my script:

#!/usr/bin/python
from gi.repository import Notify
icon = "file://~/icon.png"
Notify.init("Hello world")
Hello = Notify.Notification.new("Hello world", "This is an example notification", icon)
Hello.show()

A blank area is displayed where the icon should've been. I've also tried with an .ico format, to no avail.

Am I missing something?


Solution

  • Replace ~ in the string icon with the full name of your home directory. Notify has trouble expanding that path by itself, so make it explicit to remove the problem.