The notification api has a means to specify the id of a current notification that should be updated instead of creating a new popup, but notify-send
does not provide for this. If you are willing to use a small amount of python, you can retrieve the id of a notification when you make it, and then try to update that id later. Put the following python2 code in a file in a directory that is in your PATH, say mynotify-send
and do chmod +x mynotify-send
:
#!/usr/bin/python
import argparse, gi
#gi.require_version('Notify', '0.7')
from gi.repository import Notify
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--message', default="body")
parser.add_argument('-i', '--id', type=int)
return parser.parse_args()
def run(myid,message):
Notify.init("mynote")
obj = Notify.Notification.new("my summary", message)
obj.set_timeout(60*1000)
if myid:
obj.set_property('id', myid)
obj.show()
newid = obj.get_property('id')
print newid
else:
obj.show()
myid = obj.get_property('id')
print myid
def main():
options = parse_args()
run(options.id, options.message)
main()
You must install python-gobject
too. When you run
mynotify-send -m 'message 1'
it should popup the notification, but also print an id on stdout. Often this is just a small number counting the number of notifications, eg 6
. You can then change the message in the existing popup by adding this id:
mynotify-send --id 6 -m 'message 2'
You can do this as long as the popup exists. After the popup goes away the next message will get a new id, eg 7
, which the program prints, and you will have to use this in later messages. So basically in a shell script you would just remember the output from the program and reuse it each time.