62

Maybe I'm doing something wrong, but shouldn't the commands (run separately)

notify-send -t 1 "test"
notify-send -t 1000 "test"
notify-send -t 10000 "test"

have different timeouts? The first being nearly instantaneous, the second taking 1 sec and the third 10 seconds? In all cases it seems to take about six seconds for me.

Is there a way around this behaviour? As the developers label this as a "feature" instead of a bug, I would like some alternatives.

Hooked
  • 2,363
  • 6
    Alternatively you can use notify-send "Text Here" ; sleep 3 ; killall notify-osd (where sleep 3 is example of expiration (actually killing) after 3 seconds)! – Pandya Jan 13 '15 at 09:00
  • 1
    @Pandya Well, that also halts the execution of your script and causes what should have been an asynchronous operation to become a synchronous one.. – Makaveli84 Sep 28 '23 at 16:02

7 Answers7

55

This is a known bug: https://bugs.launchpad.net/ubuntu/+source/notify-osd/+bug/390508

(It is considered a 'design decision' by the maintainer.)

Boris Bukh
  • 751
  • 7
  • 16
  • 3
    This is not really a bug. It's a design decision. – Eren Tantekin Jun 25 '12 at 21:12
  • 89
    A wrong design decision can be a bug. – Boris Bukh Jun 29 '12 at 21:42
  • 28
    When software claims to do one thing while it does another thing, it is a bug. If the developers don't want us to consider it as bug, then don't claim that it acts like it doesn't. – hytromo Sep 24 '12 at 15:50
  • The etymology of “bug” is something creeping around that you didn't know existed. To call a design decision a bug doesn't even make sense. It's intended behavior. It's just a bad design. – Christopher Done Oct 31 '14 at 16:11
  • 1
    It was (in the end) marked as "Won't fix". – andrybak Nov 20 '14 at 15:42
  • 16
    That's not a feature. That's a bug! When you provide a a lever to turn on the windscreen wipers and it doesn't work, then it's broken. – hookenz Mar 16 '16 at 20:48
  • 6
    @ChristopherDone With respect, it's a bug. The help for notify-send (part of notify-osd) says:

    notify-send --help|grep timeout -t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification.

    That's the primary interface to a user of the tool. That primary interface lies to the user and is therefore this is a bug.

    It's either bug with the help text or the implementation, depending on your perspective, but it's definitely a bug.

    – Michael Sparks Nov 30 '17 at 14:48
  • Note that this is only for Unity (because Notify OSD is for Unity). Recent Ubuntu is based on GNOME 3. – Franklin Yu Feb 27 '20 at 18:50
24

As mentioned in one of the posts above, there is a design decision to disallow this feature. Fortunately for you, other people disagree as well and have set up a PPA and you can reverse this decision for your system as well.

To solve your problem just:

sudo add-apt-repository ppa:leolik/leolik 
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install libnotify-bin
pkill notify-osd

Optional

To add even more features to send-notify than you currently have:

From Ubuntu 16.04 onwards:

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install notifyosdconfig

For versions 9.10-14.10:

sudo add-apt-repository ppa:amandeepgrewal/notifyosdconfig
sudo apt-get update
sudo apt-get install notifyosdconfig

For more information on the solution above, read this article:

Configurable Notification Bubbles for Ubuntu

Fabby
  • 34,259
  • This worked! As clarification for anyone else though, you have to install the updated version of notify-osd as well. ie:
    `sudo add-apt-repository ppa:leolik/leolik` ; 
    `sudo add-apt-repository ppa:amandeepgrewal/notifyosdconfig` ;
    `sudo apt-get update` ;
    `sudo apt install notify-osd # Updates to actually useful version` ;
    `sudo apt install notifyosdconfig`
    
    

    Many thanks!

    – Michael Sparks Nov 30 '17 at 14:51
  • 1
    @MichaelSparks changed upgrade to dist-upgrade. That should take care of things as notify-osd is already installed and should be upgraded for sure. – Fabby Dec 02 '17 at 21:24
4

This was an intentionally implemented contravention of established conventions without disqualification in the host terminal environment. ie. notify-send should no longer exist since it compromises the well-established expected and documented functionality, so instead, a new command notify-graffiti should now exist - What???? Wait a second ... all those scripts that use the "conventional" command name spelling will be compromised!?! by changing the convention of how the command name is spelled?!?! - hmmm This philosophy is exceptionally, paradoxically hypocritical as espoused by the Unity desktop terminal interface.

It can't be done both ways - preserving some conventions ie. the name of a command and yet not others, the functionality of a command as documented. If the functionality is to be compromised then so too should the command name so as to maintain integrity, conventionality, consistency, etc. of the user "experience", or is that user "frustration", "annoyance", "irritation", ...

ref:

Bookmark:
Notify-send ignores timeout?

  • The "Non-expiring_notifications" and "Notification | Ubuntu App Developer" links are broken (or rather the web page they refer to is). – Keith Thompson Dec 17 '15 at 01:17
4

There is a small handy script notify-send.sh as a drop-in replacement for notify-send that enables you to close or replace previously sent notifications.

Edit: as @Glutanimate pointed out, this script supports expiration-time by default.

I couldn't get expiration-time to work in the end, so I went rather a hacky way to send a notification with 2 seconds timeout like this:

notify-send.sh --print-id test | xargs -I {} bash -c "sleep 2 && notify-send.sh --close={}" &
Zanna
  • 70,465
NiMa Thr
  • 341
  • 2
  • 7
  • This script is great! Thanks for sharing it here. Looks like it's now completely compatible with notify-send's original CLI arguments. I.e.: You can send a notification with a 2 sec timeout via notify-send.sh -t 2 "Hello World!". I've symlinked the script to my local $PATH directory and renamed it to notify-send. No more dealing with that subpar notify-osd implementation! – Glutanimate Apr 09 '18 at 18:30
  • Oh cool @Glutanimate ! Thanks for letting us know about it. – NiMa Thr Apr 10 '18 at 18:35
  • Thanks for your hacky way, still useful on Debian 11 / Gnome 3.38 (-t has no effect, see issue https://github.com/vlevit/notify-send.sh/issues/28). I also had to add -u critical to your hacky way for it to work. – ChennyStar Nov 03 '22 at 08:44
2

This is in milliseconds. I tested on XUbuntu 16.04 (Ubuntu XFCE)

notify-send -t 3000 "test"

exactly 3 seconds

Zanna
  • 70,465
2

Yes, if you use notify-send -u critical -t 0 the notification will stay on the screen until you click it.

quoted from this answer

1

For those using the Cinnamon desktop environment, there's a setting that can be enabled:

Notifications > Remove notifications after their timeout is reached

Zanna
  • 70,465