I created a simple python script that works nearly the same as notify-send but has support for
A python script for sending desktop notifications from the shell.
Libnotify is part of many scripts in the Linux world. It utilizes many
of the specified features of the Desktop Notifications Specification
and makes them accessible to shell-scripts. It does not however
allow to replace an existing notification with the
is a known bug since 2008 and has a patch since 2012. The patch is still not
upstream though (2018).
This python script utilizes the notify2 package and exposes the
functionality to the shell.
Differences between notify-send.py and notify-send
notify-send.py -h shows help instead of being the parameter for
hints. For hints use
notify-send.py -r ID and
notify-send.py --replaces-id ID
exists. In order to replace a notification call
with the ID that was returned by the notification to be replaced.
notify-send.py returns the ID of the newly created notification.
notify-send.py --replaces-process NAME exists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
notify-send.py might block, best to be called with a
git clone https://github.com/phuhl/notify-send.py
sudo pip install notify2
sudo python setup.py install
$ notify-send.py -h
usage: notify-send.py [-h] [-u LEVEL] [-t TIME] [-a APP_NAME]
[-i ICON[,ICON...]] [-c TYPE[,TYPE...]]
[--hint TYPE:NAME:VALUE] [-r ID]
-h, --help show this help message and exit
-u LEVEL, --urgency LEVEL
Specifies the urgency level (low, normal, critical).
-t TIME, --expire-time TIME
Specifies the timeout in milliseconds at which to
expire the notification.
-a APP_NAME, --app-name APP_NAME
Specifies the app name for the icon
-i ICON[,ICON...], --icon ICON[,ICON...]
Specifies an icon filename or stock icon to display.
-c TYPE[,TYPE...], --category TYPE[,TYPE...]
Specifies the notification category.
Specifies basic extra data to pass. Valid typesare
int, double, string and byte.
-r ID, --replaces-id ID
Specifies the id of the notification that should be
Specifies the name of a process that should take care
of replacing notifications for this process.
notify-send[.py] as root user
In order to display notifications, even if libnotify or
is used from the root user these two scripts are helpful.
username=<your username here>
if [ "$(id -u)" != "1000" ] ; then
sudo -u $username DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send.sh "$@"
notify-send.sh like this:
notify-send.py "$@" &
Also take a look at my notification-daemon inspired by Dunst, but with several improvements, including the possibility of a transparent background and a notification center that stores notifications.