Search code examples
pythonlinuxlinux-mintpynotify

pynotify linux changing the text


I'm using the pynotify module in python in linux (linux mint 15), and I want to know if there's a good way to change the text in a notification without making a new notification.

So lets say I have this:

pynotify.init("app_name")
n = pynotify.Notification("", "message A", icon='some_icon')
n.set_urgency(pynotify.URGENCY_CRITICAL)
n.set_timeout(1000)
n.show()        

If I wanted to make it so the notification said "message B" instead, is that possible without making a new notification? I'm looking to change the notification on the fly.

Thanks!


Solution

  • Use Notification.update

    pynotify.init("app_name")
    n = pynotify.Notification("", "message A", icon='some_icon')
    n.set_urgency(pynotify.URGENCY_CRITICAL)
    n.set_timeout(1000)
    n.show()
    n.update("","message B")
    n.show()