done
done copied to clipboard
Option to time limit notifications (`notify-send --expire-time …`)
I generally love using your package (I get alerted when long compilation or test run on another desktop is over), but I repeatably end up with 3-6 notifications hanging on the screen as closing them is unpleasant.
It would be nice if they could disappear by themselves.
I changed line 222 of done.fish
to:
notify-send --urgency=$urgency --icon=utilities-terminal --app-name=fish --expire-time=60000 "$title" "$message"
and my notifications nicely disappear after 60 seconds under KDE Plasma.
I noticed that notify-send
manpage claims that Gnome Shell ignores this param, and I do not know how well it is supported by non-Linux tools, but … well, there is at least one popular desktop which handles that limit properly.
Of course hardcoding 60s is bad idea, whether such time limit is used and which should be configurable via some variable (and in case it is enabled by default, sth like 5 mins seems more reasonable).
Example of the feature working under KDE plasma. That green circle measures time until notification will go – and indeed it disappeared while I was writing this sentence. Remaining notifications were created before I patched done
, so they were created 21, 25, and 30 minutes ago (and as you can see I still haven't closed them)
@charliemaiors you have worked on notify-send support, do you know what is the compatibility of this parameter in other distributions and versions? Thanks!
Some technicalities:
-
notify-send
on API level documents this setting as https://developer.gnome.org/libnotify/unstable/NotifyNotification.html#notify-notification-set-timeout – again „may not work, but won't spoil things”. - implementation-wise
notify-send
/libnotify
implement it's API by sending D-Bus message toorg.freedesktop.Notifications.Notify
(giving timeout as last argument), spec claims this arg should be supported https://developer.gnome.org/notification-spec/ - there are numerous implementations ( https://wiki.archlinux.org/index.php/Desktop_notifications ), of course some more popular than others
I also found macabresque discussion about implementing this timeout in notify-OSD (unity module) https://bugs.launchpad.net/ubuntu/+source/notify-osd/+bug/390508
Worth noting that people repeatably suggest apt-get remove notify-osd; apt-get install notification-daemon
as a solution (to get notification server which properly handles timeouts). So there is at least one alternative to KDE which works.
So, going back to be practical: some devs of notification services implement this setting, others don't implement it for philosophical reasons (because they „know better” when to discard notifications). Services written with the latter approach most likely flush those notifications automatically after some time, so their users are less likely to need this setting.
Therefore, cfg variable like __done_notification_expire
described like: „if set, causes notifications to automatically disappear after given time (in miliseconds, 60000=60 seconds). This setting works depending on the notification implementation you use (for example, it works under KDE Plasma, but doesn't work with Gnome Shell default notifications)” would do. Technically it's just about adding -t $__done_notification_expire
to notify-send
if such variable is set.
Hi
I'm using gnome 3.36 and I just added --expire-time=60000
to notify-send
command in done.fish
file, just like @Mekk said, and it works perfectly. Please note that I didn't change any config or package in my OS (like replacing notify-send
with some other lib).
My config:
Ubuntu: 20.04
Gnome: 3.36.8
libnotify-bin (which provides notify-send): 0.7.9-1ubuntu2
fish: 3.1.2
done: 1.14.9
I use Manjaro (Arch-based) --expire-time=2000
works out-of-the box, but not for ssh sesssions... don't know why, maybe it is tied to the exit status of the process?
configuration:
System: Host: claude Kernel: 5.4.116-1-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.21.4 Distro: Manjaro Linux
Graphics: Device-1: Intel UHD Graphics 620 driver: i915 v: kernel
Device-2: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo
Display: x11 server: X.Org 1.20.11 driver: loaded: intel unloaded: modesetting resolution: 1920x1080~60Hz
OpenGL: renderer: Mesa Intel UHD Graphics 620 (KBL GT2) v: 4.6 Mesa 21.0.3
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
This was made available in v1.18.0 by https://github.com/franciscolourenco/done/pull/125/files
Thank you, works nicely.