How do I use 'notify-send' to immediately replace an existing notification?
up vote
18
down vote
favorite
When I use notify-send to show a notification on the desktop, and then use it again to show a different notification, I have noticed that the second one only shows after the first one has disappeared.
Is there a way to get notify-send to immediately replace an existing notification with a different one?
command-line bash notification notify-osd
add a comment |
up vote
18
down vote
favorite
When I use notify-send to show a notification on the desktop, and then use it again to show a different notification, I have noticed that the second one only shows after the first one has disappeared.
Is there a way to get notify-send to immediately replace an existing notification with a different one?
command-line bash notification notify-osd
add a comment |
up vote
18
down vote
favorite
up vote
18
down vote
favorite
When I use notify-send to show a notification on the desktop, and then use it again to show a different notification, I have noticed that the second one only shows after the first one has disappeared.
Is there a way to get notify-send to immediately replace an existing notification with a different one?
command-line bash notification notify-osd
When I use notify-send to show a notification on the desktop, and then use it again to show a different notification, I have noticed that the second one only shows after the first one has disappeared.
Is there a way to get notify-send to immediately replace an existing notification with a different one?
command-line bash notification notify-osd
command-line bash notification notify-osd
edited Jul 11 '12 at 20:29
asked Jul 10 '12 at 5:54
ish
114k28262290
114k28262290
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
up vote
14
down vote
accepted
You can, but you must use a patched libnotify to do so
notify-send does not have the capability to replace existing notifications before they have timed out (or disappeared). This is a known bug. However, a commenter on the bug report has posted a patch to fix it.
Installing the patched libnotify-bin from PPA
I have created a patched version of the libnotify-bin package which allows replacements in my PPA. Currently it's for Ubuntu 12.04 only, but if you need it for any other currently supported release, please post a comment and I will try my best to make it available.
To install, open a terminal and:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
How to use the replacement capabilities
The patched notify-send includes two new switches, -p (or --print-id ), and -r (or --replace-id ). The --help describes them as:
-p, --print-id Print the notification ID.
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
- With
-p, eachnotify-sendwill return an ID N (number/integer). - Issuing another
notify-sendwith-r Nwill replace the previous notification immediately.
For example, for bash, you can save the ID from
notify-send -p ...with:
NID=$(notify-send -p "MESSAGE-1")
and then replace it with:
notify-send -r $NID "MESSAGE-2"
You can recursively use both -p and -r in a script, as long as the -r variable is initialized to 0 at the beginning.
Here's a simple script that shows notifications counting from 0 to 100 at half-second intervals:
#!/bin/bash
NID=0
for i in {0..100..10}
do
NID=$(notify-send -p -r $NID $i)
sleep 0.5
done
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
add a comment |
up vote
10
down vote
X-ref:
How to force a new Notification in notify-osd to show up without waiting for the earlier one to exit?
without patches you can simply do
#!/bin/bash
for i in {0..100..10}
do
killall notify-osd
notify-send "testing" $i
sleep 1
done
Bookmark:
How do I use 'notify-send' to immediately replace an existing notification?
Sends an error notify-osd(2592): Operation not permitted. What does that mean?
It may mean that privileges are inadequate requiring:
sudo killall notify-osd
Sends an errornotify-osd(2592): Operation not permitted. What does that mean?
– VedVals
Nov 12 '12 at 18:22
add a comment |
up vote
8
down vote
You can use the "synchronous" hint to create a "confirmation" notification that will replace previous confirmation notifications. For example:
notify-send "Message" -h string:x-canonical-private-synchronous:anything
The "x-canonical-private-synchronous" hint is specified in this document. To specify a hint, use -h type:name:value. The type here is string, name is x-canonical-private-synchronous, and it seems that the value can be whatever you want.
So if your first notification is created with that hint and the second is as well, the second will immediately replace the first. (See Animations and Durations in the documentation, in the column for "confirmation bubbles".)
string:x-canonical-private-synchronous:anythingwas exactly what i needed. Thanks for this answer. Also for linking to the documentation
– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
add a comment |
up vote
2
down vote
I created a simple python script that works nearly the same as notify-send but has support for --replaces-id.
notify-send.py
web: https://github.com/phuhl/notify-send.py
A python script for sending desktop notifications from the shell.
About
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 replaces-id. This
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
- In
notify-send.py -hshows help instead of being the parameter for
hints. For hints use--hint. - In
notify-send.py -r IDandnotify-send.py --replaces-id ID
exists. In order to replace a notification callnotify-send.py
with the ID that was returned by the notification to be replaced.
notify-send.pyreturns the ID of the newly created notification.
notify-send.py --replaces-process NAMEexists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
parameternotify-send.pymight block, best to be called with a
trailing&.
Installation
Requires python3.
git clone https://github.com/phuhl/notify-send.py
cd notify-send.py
sudo pip install notify2
sudo python setup.py install
Usage
$ 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]
[--replaces-process NAME]
SUMMERY [BODY]
positional arguments:
SUMMERY
BODY
optional arguments:
-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.
--hint TYPE:NAME:VALUE
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
replaced.
--replaces-process NAME
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
notify-send.py
is used from the root user these two scripts are helpful.
#!/bin/bash
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 "$@"
else
notify-send.sh "$@"
fi
With notify-send.sh like this:
#!/bin/bash
notify-send.py "$@" &
See also
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.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
14
down vote
accepted
You can, but you must use a patched libnotify to do so
notify-send does not have the capability to replace existing notifications before they have timed out (or disappeared). This is a known bug. However, a commenter on the bug report has posted a patch to fix it.
Installing the patched libnotify-bin from PPA
I have created a patched version of the libnotify-bin package which allows replacements in my PPA. Currently it's for Ubuntu 12.04 only, but if you need it for any other currently supported release, please post a comment and I will try my best to make it available.
To install, open a terminal and:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
How to use the replacement capabilities
The patched notify-send includes two new switches, -p (or --print-id ), and -r (or --replace-id ). The --help describes them as:
-p, --print-id Print the notification ID.
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
- With
-p, eachnotify-sendwill return an ID N (number/integer). - Issuing another
notify-sendwith-r Nwill replace the previous notification immediately.
For example, for bash, you can save the ID from
notify-send -p ...with:
NID=$(notify-send -p "MESSAGE-1")
and then replace it with:
notify-send -r $NID "MESSAGE-2"
You can recursively use both -p and -r in a script, as long as the -r variable is initialized to 0 at the beginning.
Here's a simple script that shows notifications counting from 0 to 100 at half-second intervals:
#!/bin/bash
NID=0
for i in {0..100..10}
do
NID=$(notify-send -p -r $NID $i)
sleep 0.5
done
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
add a comment |
up vote
14
down vote
accepted
You can, but you must use a patched libnotify to do so
notify-send does not have the capability to replace existing notifications before they have timed out (or disappeared). This is a known bug. However, a commenter on the bug report has posted a patch to fix it.
Installing the patched libnotify-bin from PPA
I have created a patched version of the libnotify-bin package which allows replacements in my PPA. Currently it's for Ubuntu 12.04 only, but if you need it for any other currently supported release, please post a comment and I will try my best to make it available.
To install, open a terminal and:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
How to use the replacement capabilities
The patched notify-send includes two new switches, -p (or --print-id ), and -r (or --replace-id ). The --help describes them as:
-p, --print-id Print the notification ID.
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
- With
-p, eachnotify-sendwill return an ID N (number/integer). - Issuing another
notify-sendwith-r Nwill replace the previous notification immediately.
For example, for bash, you can save the ID from
notify-send -p ...with:
NID=$(notify-send -p "MESSAGE-1")
and then replace it with:
notify-send -r $NID "MESSAGE-2"
You can recursively use both -p and -r in a script, as long as the -r variable is initialized to 0 at the beginning.
Here's a simple script that shows notifications counting from 0 to 100 at half-second intervals:
#!/bin/bash
NID=0
for i in {0..100..10}
do
NID=$(notify-send -p -r $NID $i)
sleep 0.5
done
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
add a comment |
up vote
14
down vote
accepted
up vote
14
down vote
accepted
You can, but you must use a patched libnotify to do so
notify-send does not have the capability to replace existing notifications before they have timed out (or disappeared). This is a known bug. However, a commenter on the bug report has posted a patch to fix it.
Installing the patched libnotify-bin from PPA
I have created a patched version of the libnotify-bin package which allows replacements in my PPA. Currently it's for Ubuntu 12.04 only, but if you need it for any other currently supported release, please post a comment and I will try my best to make it available.
To install, open a terminal and:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
How to use the replacement capabilities
The patched notify-send includes two new switches, -p (or --print-id ), and -r (or --replace-id ). The --help describes them as:
-p, --print-id Print the notification ID.
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
- With
-p, eachnotify-sendwill return an ID N (number/integer). - Issuing another
notify-sendwith-r Nwill replace the previous notification immediately.
For example, for bash, you can save the ID from
notify-send -p ...with:
NID=$(notify-send -p "MESSAGE-1")
and then replace it with:
notify-send -r $NID "MESSAGE-2"
You can recursively use both -p and -r in a script, as long as the -r variable is initialized to 0 at the beginning.
Here's a simple script that shows notifications counting from 0 to 100 at half-second intervals:
#!/bin/bash
NID=0
for i in {0..100..10}
do
NID=$(notify-send -p -r $NID $i)
sleep 0.5
done
You can, but you must use a patched libnotify to do so
notify-send does not have the capability to replace existing notifications before they have timed out (or disappeared). This is a known bug. However, a commenter on the bug report has posted a patch to fix it.
Installing the patched libnotify-bin from PPA
I have created a patched version of the libnotify-bin package which allows replacements in my PPA. Currently it's for Ubuntu 12.04 only, but if you need it for any other currently supported release, please post a comment and I will try my best to make it available.
To install, open a terminal and:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin
How to use the replacement capabilities
The patched notify-send includes two new switches, -p (or --print-id ), and -r (or --replace-id ). The --help describes them as:
-p, --print-id Print the notification ID.
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
- With
-p, eachnotify-sendwill return an ID N (number/integer). - Issuing another
notify-sendwith-r Nwill replace the previous notification immediately.
For example, for bash, you can save the ID from
notify-send -p ...with:
NID=$(notify-send -p "MESSAGE-1")
and then replace it with:
notify-send -r $NID "MESSAGE-2"
You can recursively use both -p and -r in a script, as long as the -r variable is initialized to 0 at the beginning.
Here's a simple script that shows notifications counting from 0 to 100 at half-second intervals:
#!/bin/bash
NID=0
for i in {0..100..10}
do
NID=$(notify-send -p -r $NID $i)
sleep 0.5
done
answered Jul 10 '12 at 5:54
ish
114k28262290
114k28262290
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
add a comment |
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
I get 404 for ppa.launchpad.net/izx/askubuntu/ubuntu/dists/trusty/main/…. Is this repository outdated?
– vp_arth
Nov 11 '15 at 8:18
1
1
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
You can use my python script that works like notify-send: github.com/phuhl/notify-send.py
– user3637541
Nov 22 at 5:24
add a comment |
up vote
10
down vote
X-ref:
How to force a new Notification in notify-osd to show up without waiting for the earlier one to exit?
without patches you can simply do
#!/bin/bash
for i in {0..100..10}
do
killall notify-osd
notify-send "testing" $i
sleep 1
done
Bookmark:
How do I use 'notify-send' to immediately replace an existing notification?
Sends an error notify-osd(2592): Operation not permitted. What does that mean?
It may mean that privileges are inadequate requiring:
sudo killall notify-osd
Sends an errornotify-osd(2592): Operation not permitted. What does that mean?
– VedVals
Nov 12 '12 at 18:22
add a comment |
up vote
10
down vote
X-ref:
How to force a new Notification in notify-osd to show up without waiting for the earlier one to exit?
without patches you can simply do
#!/bin/bash
for i in {0..100..10}
do
killall notify-osd
notify-send "testing" $i
sleep 1
done
Bookmark:
How do I use 'notify-send' to immediately replace an existing notification?
Sends an error notify-osd(2592): Operation not permitted. What does that mean?
It may mean that privileges are inadequate requiring:
sudo killall notify-osd
Sends an errornotify-osd(2592): Operation not permitted. What does that mean?
– VedVals
Nov 12 '12 at 18:22
add a comment |
up vote
10
down vote
up vote
10
down vote
X-ref:
How to force a new Notification in notify-osd to show up without waiting for the earlier one to exit?
without patches you can simply do
#!/bin/bash
for i in {0..100..10}
do
killall notify-osd
notify-send "testing" $i
sleep 1
done
Bookmark:
How do I use 'notify-send' to immediately replace an existing notification?
Sends an error notify-osd(2592): Operation not permitted. What does that mean?
It may mean that privileges are inadequate requiring:
sudo killall notify-osd
X-ref:
How to force a new Notification in notify-osd to show up without waiting for the earlier one to exit?
without patches you can simply do
#!/bin/bash
for i in {0..100..10}
do
killall notify-osd
notify-send "testing" $i
sleep 1
done
Bookmark:
How do I use 'notify-send' to immediately replace an existing notification?
Sends an error notify-osd(2592): Operation not permitted. What does that mean?
It may mean that privileges are inadequate requiring:
sudo killall notify-osd
edited Apr 13 '17 at 12:23
Community♦
1
1
answered Sep 19 '12 at 3:37
george rowell
4801511
4801511
Sends an errornotify-osd(2592): Operation not permitted. What does that mean?
– VedVals
Nov 12 '12 at 18:22
add a comment |
Sends an errornotify-osd(2592): Operation not permitted. What does that mean?
– VedVals
Nov 12 '12 at 18:22
Sends an error
notify-osd(2592): Operation not permitted. What does that mean?– VedVals
Nov 12 '12 at 18:22
Sends an error
notify-osd(2592): Operation not permitted. What does that mean?– VedVals
Nov 12 '12 at 18:22
add a comment |
up vote
8
down vote
You can use the "synchronous" hint to create a "confirmation" notification that will replace previous confirmation notifications. For example:
notify-send "Message" -h string:x-canonical-private-synchronous:anything
The "x-canonical-private-synchronous" hint is specified in this document. To specify a hint, use -h type:name:value. The type here is string, name is x-canonical-private-synchronous, and it seems that the value can be whatever you want.
So if your first notification is created with that hint and the second is as well, the second will immediately replace the first. (See Animations and Durations in the documentation, in the column for "confirmation bubbles".)
string:x-canonical-private-synchronous:anythingwas exactly what i needed. Thanks for this answer. Also for linking to the documentation
– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
add a comment |
up vote
8
down vote
You can use the "synchronous" hint to create a "confirmation" notification that will replace previous confirmation notifications. For example:
notify-send "Message" -h string:x-canonical-private-synchronous:anything
The "x-canonical-private-synchronous" hint is specified in this document. To specify a hint, use -h type:name:value. The type here is string, name is x-canonical-private-synchronous, and it seems that the value can be whatever you want.
So if your first notification is created with that hint and the second is as well, the second will immediately replace the first. (See Animations and Durations in the documentation, in the column for "confirmation bubbles".)
string:x-canonical-private-synchronous:anythingwas exactly what i needed. Thanks for this answer. Also for linking to the documentation
– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
add a comment |
up vote
8
down vote
up vote
8
down vote
You can use the "synchronous" hint to create a "confirmation" notification that will replace previous confirmation notifications. For example:
notify-send "Message" -h string:x-canonical-private-synchronous:anything
The "x-canonical-private-synchronous" hint is specified in this document. To specify a hint, use -h type:name:value. The type here is string, name is x-canonical-private-synchronous, and it seems that the value can be whatever you want.
So if your first notification is created with that hint and the second is as well, the second will immediately replace the first. (See Animations and Durations in the documentation, in the column for "confirmation bubbles".)
You can use the "synchronous" hint to create a "confirmation" notification that will replace previous confirmation notifications. For example:
notify-send "Message" -h string:x-canonical-private-synchronous:anything
The "x-canonical-private-synchronous" hint is specified in this document. To specify a hint, use -h type:name:value. The type here is string, name is x-canonical-private-synchronous, and it seems that the value can be whatever you want.
So if your first notification is created with that hint and the second is as well, the second will immediately replace the first. (See Animations and Durations in the documentation, in the column for "confirmation bubbles".)
answered Jan 12 '17 at 20:14
Mark L
10113
10113
string:x-canonical-private-synchronous:anythingwas exactly what i needed. Thanks for this answer. Also for linking to the documentation
– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
add a comment |
string:x-canonical-private-synchronous:anythingwas exactly what i needed. Thanks for this answer. Also for linking to the documentation
– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
string:x-canonical-private-synchronous:anything was exactly what i needed. Thanks for this answer. Also for linking to the documentation– avk
Jun 30 '17 at 8:33
string:x-canonical-private-synchronous:anything was exactly what i needed. Thanks for this answer. Also for linking to the documentation– avk
Jun 30 '17 at 8:33
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
It doesn't work with GNOME....
– Johannes Lemonde
Jul 12 '17 at 14:53
add a comment |
up vote
2
down vote
I created a simple python script that works nearly the same as notify-send but has support for --replaces-id.
notify-send.py
web: https://github.com/phuhl/notify-send.py
A python script for sending desktop notifications from the shell.
About
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 replaces-id. This
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
- In
notify-send.py -hshows help instead of being the parameter for
hints. For hints use--hint. - In
notify-send.py -r IDandnotify-send.py --replaces-id ID
exists. In order to replace a notification callnotify-send.py
with the ID that was returned by the notification to be replaced.
notify-send.pyreturns the ID of the newly created notification.
notify-send.py --replaces-process NAMEexists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
parameternotify-send.pymight block, best to be called with a
trailing&.
Installation
Requires python3.
git clone https://github.com/phuhl/notify-send.py
cd notify-send.py
sudo pip install notify2
sudo python setup.py install
Usage
$ 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]
[--replaces-process NAME]
SUMMERY [BODY]
positional arguments:
SUMMERY
BODY
optional arguments:
-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.
--hint TYPE:NAME:VALUE
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
replaced.
--replaces-process NAME
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
notify-send.py
is used from the root user these two scripts are helpful.
#!/bin/bash
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 "$@"
else
notify-send.sh "$@"
fi
With notify-send.sh like this:
#!/bin/bash
notify-send.py "$@" &
See also
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.
add a comment |
up vote
2
down vote
I created a simple python script that works nearly the same as notify-send but has support for --replaces-id.
notify-send.py
web: https://github.com/phuhl/notify-send.py
A python script for sending desktop notifications from the shell.
About
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 replaces-id. This
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
- In
notify-send.py -hshows help instead of being the parameter for
hints. For hints use--hint. - In
notify-send.py -r IDandnotify-send.py --replaces-id ID
exists. In order to replace a notification callnotify-send.py
with the ID that was returned by the notification to be replaced.
notify-send.pyreturns the ID of the newly created notification.
notify-send.py --replaces-process NAMEexists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
parameternotify-send.pymight block, best to be called with a
trailing&.
Installation
Requires python3.
git clone https://github.com/phuhl/notify-send.py
cd notify-send.py
sudo pip install notify2
sudo python setup.py install
Usage
$ 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]
[--replaces-process NAME]
SUMMERY [BODY]
positional arguments:
SUMMERY
BODY
optional arguments:
-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.
--hint TYPE:NAME:VALUE
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
replaced.
--replaces-process NAME
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
notify-send.py
is used from the root user these two scripts are helpful.
#!/bin/bash
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 "$@"
else
notify-send.sh "$@"
fi
With notify-send.sh like this:
#!/bin/bash
notify-send.py "$@" &
See also
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.
add a comment |
up vote
2
down vote
up vote
2
down vote
I created a simple python script that works nearly the same as notify-send but has support for --replaces-id.
notify-send.py
web: https://github.com/phuhl/notify-send.py
A python script for sending desktop notifications from the shell.
About
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 replaces-id. This
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
- In
notify-send.py -hshows help instead of being the parameter for
hints. For hints use--hint. - In
notify-send.py -r IDandnotify-send.py --replaces-id ID
exists. In order to replace a notification callnotify-send.py
with the ID that was returned by the notification to be replaced.
notify-send.pyreturns the ID of the newly created notification.
notify-send.py --replaces-process NAMEexists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
parameternotify-send.pymight block, best to be called with a
trailing&.
Installation
Requires python3.
git clone https://github.com/phuhl/notify-send.py
cd notify-send.py
sudo pip install notify2
sudo python setup.py install
Usage
$ 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]
[--replaces-process NAME]
SUMMERY [BODY]
positional arguments:
SUMMERY
BODY
optional arguments:
-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.
--hint TYPE:NAME:VALUE
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
replaced.
--replaces-process NAME
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
notify-send.py
is used from the root user these two scripts are helpful.
#!/bin/bash
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 "$@"
else
notify-send.sh "$@"
fi
With notify-send.sh like this:
#!/bin/bash
notify-send.py "$@" &
See also
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.
I created a simple python script that works nearly the same as notify-send but has support for --replaces-id.
notify-send.py
web: https://github.com/phuhl/notify-send.py
A python script for sending desktop notifications from the shell.
About
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 replaces-id. This
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
- In
notify-send.py -hshows help instead of being the parameter for
hints. For hints use--hint. - In
notify-send.py -r IDandnotify-send.py --replaces-id ID
exists. In order to replace a notification callnotify-send.py
with the ID that was returned by the notification to be replaced.
notify-send.pyreturns the ID of the newly created notification.
notify-send.py --replaces-process NAMEexists.
Every notification that gets created with the same NAME will replace
every notification before it with the same NAME. If called with this
parameternotify-send.pymight block, best to be called with a
trailing&.
Installation
Requires python3.
git clone https://github.com/phuhl/notify-send.py
cd notify-send.py
sudo pip install notify2
sudo python setup.py install
Usage
$ 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]
[--replaces-process NAME]
SUMMERY [BODY]
positional arguments:
SUMMERY
BODY
optional arguments:
-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.
--hint TYPE:NAME:VALUE
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
replaced.
--replaces-process NAME
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
notify-send.py
is used from the root user these two scripts are helpful.
#!/bin/bash
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 "$@"
else
notify-send.sh "$@"
fi
With notify-send.sh like this:
#!/bin/bash
notify-send.py "$@" &
See also
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.
edited Nov 22 at 15:22
abu_bua
3,07081023
3,07081023
answered Nov 22 at 5:24
user3637541
1211
1211
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f161851%2fhow-do-i-use-notify-send-to-immediately-replace-an-existing-notification%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown