This is a development related question and cross posted (for reference). I am using following code for showing notification,

import subprocess as s
import os

img =  os.path.abspath('icon.svg')
s.Popen(["notify-send", "-i", img, "Title", "some text"])

In elementary os, this is working with the exception of icon. No icon is being shown. In Ubuntu 16.04, however, everything is working as expected (including icon).

Since no warning/error is shown, I am not sure what needs to be done. The developer page for showing notification in Elementary shows usage with vala (especially this line of code var image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG)) but I intend to stick with python (additionally, I don't understand vala as of now).

1 Answer 1


This is my first time answering something on stack exchange. I found your post while trying to figure out the same problem. Finally found the answer on this site http://www.devdungeon.com/content/desktop-notifications-python-libnotify

I realize you are using subprocess but i also tried it and had the same problem. The code below may need some tweaking for subprocess to work.

I initially thought that i had to somehow set the image using Gtk.Image, several googles seems to lead to that, and it came down to setting the pixbuf and then setting the icon from there. This is my first time doing a script in Python and Gtk.

Anyway, the answer from the site is below. I followed exactly the same and managed to show my png file in the notification.

# This time import the GdkPixbuf module
from gi.repository import Notify, GdkPixbuf

Notify.init("Test App")
notification = Notify.Notification.new("Alert!")

# Use GdkPixbuf to create the proper image type
image = GdkPixbuf.Pixbuf.new_from_file("/home/NanoDano/test.png")

# Use the GdkPixbuf image

  • Appreciate your help but I have ditched native python development in favor of Electron. However, since the code you shared seems to be working in Elementary OS, I am marking your solution as answer.
    – Paritosh
    Feb 6, 2017 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.