franciscolourenco / done

A fish-shell package to automatically receive notifications when long processes finish.
MIT License
766 stars 70 forks source link

Option to time limit notifications (`notify-send --expire-time …`) #97

Closed Mekk closed 8 months ago

Mekk commented 3 years ago

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).

Mekk commented 3 years ago

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)

obraz

franciscolourenco commented 3 years ago

@charliemaiors you have worked on notify-send support, do you know what is the compatibility of this parameter in other distributions and versions? Thanks!

Mekk commented 3 years ago

Some technicalities:

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.

Mekk commented 3 years ago

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.

sazary commented 3 years ago

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
00sapo commented 3 years ago

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
zheyuanWang commented 2 years ago

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

franciscolourenco commented 8 months ago

This was made available in v1.18.0 by https://github.com/franciscolourenco/done/pull/125/files

Mekk commented 6 months ago

Thank you, works nicely.