dunst
dunst copied to clipboard
Feature Request: Do Not Disturb mode
I'd like to be able to optionally temporarily suppress certain kinds of notifications (Slack, Discord, …). However, I need to not suppress them all (still wish to see urgent notifications about low battery, possibly non-urgent notifications from Calendar), therefore dunstctl set-paused
isn't sufficient.
I have a few ideas how to implement this:
- Add a
dnd
mode that is similar topause
, but only defers notifications that have askip_display_dnd = true
rule - Invoke
script
s synchronously and let them somehow set attributes likeskip_display
I'd be willing to try implementing this, but I'd love to discuss how to best approach this first.
This would probably be a useful feature to natively include. I like your dnd
proposal more, because it's easier to implement and easier to use. Doing it with scripts would be a bit more flexible, but I don't see the use of it. Dunst would also have to wait for the script to finish before it can display the notification.
I don't think we need to make a new mode. We can just implement display_paused
or something. The name "do not disturb" would be more fitting, but I don't think we should make a new mode for that. I would be open to renaming it though, if we can maintain some sort of backwards compatibility.
Yeah, repurposing pause
might work as well. I can imagine that people who actually pause
dunst when the screen saver/locker is active might want pause
and dnd
to be separate, but I don't do that so I'm completely fine with this.
Regarding the rename, I'm not sure it's necessary. pause
has been there for a while and it was the first thing I'd try if there was the option to not pause all notifications. It also makes it easy to see that notifications aren't discarded, just deferred.
Maybe add an optional parameter to pause
to choose an urgency level (and/or something like pause_urgency) that is not held back?
Yeah, repurposing
pause
might work as well. I can imagine that people who actuallypause
dunst when the screen saver/locker is active might wantpause
anddnd
to be separate, but I don't do that so I'm completely fine with this.Regarding the rename, I'm not sure it's necessary.
pause
has been there for a while and it was the first thing I'd try if there was the option to not pause all notifications. It also makes it easy to see that notifications aren't discarded, just deferred.
I didn't think of what the pause mode was currently used for. I now think it should be separate from the dnd mode, because they have separate uses. One might want to use do not disturb for suppressing notifications from certains apps and pause mode when they lock their computer.
Maybe add an optional parameter to
pause
to choose an urgency level (and/or something like pause_urgency) that is not held back?
This could work, but is less flexible than a rulable skip_display_dnd
. You will have to make your system notifications like a calendar all critical urgency and style them like a normal notification again. I like simple rulable settings over separate settings for multiple cases.
Keep in mind that you could do
[urgency_critical]
skip_display_dnd = false
to achieve the same thing.
In conclusion I think the best proposal is to add a "do not disturb mode" next to the pause mode. It can be controlled by a rulable skip_display_dnd
(there might be a better name for that) which is set to false by default. It might make sense to set skip_display_dnd
to true for low urgency notifications by default.
For implementing it, I would recommend to build it on top of my #803 branch. That will safe me redoing the settings afterwards and it should be easier to use. You cannot simply copy the pause mode, since it stops dunst entirely. Instead you can look at how skip_display is implemented.
I'm nearly satisfied with pausing as a makeshift DND, but despite having the option always_run_script = true
in my dunstrc scripts don't appear to run while in a "paused" state.
While I believe this may be intended behavior, my intent is to run a script which sends updates the notification count (read by dunstctl count waiting
) by sending a signal to i3blocks via (pkill -RTMIN+2 i3blocks
)
It's not impossible to work around (as I can just query dunstctl count waiting
periodically), but I believe running a script to send a signal is more effective.
(It's been a while since I proposed this, so I should probably post an update: It's still something I want and that is somewhere in my TODO list, but it's not top priority because I've been somewhat lucky with simply not having all that many notifications to suppress.)
One thing to consider is what happens when you exit DND mode. For me personally, I would prefer all suppressed notifications to come back (similarly to how pause works at the moment). In this case, skip_display_dnd
would not be the best name, since notifications would just be deferred, not entirely skipped.
How about this?
We introduce set-pause-level
and get-pause-level
commands to dunst.
Property can be:
0 - no pause 1 - pause only low urgency 2 - pause low and normal urgency 3 - pause everything
old paused commands would be deprecated, but for compatibility reasons, we can still keep them (set-paused
would just toggle between pause levels 0 and 3).
When notification is "paused", it would behave similarly to how paused notifications behave now, they would not be displayed, but stored. When pause level for that notification is lifted, notification would be displayed back.
This seems like a good compromise that also takes into account existing pause features. If current maintainers agree, I would even try to implement a PR for this.
I don't think you want to couple the display of notifications in do-not-disturb mode to the urgency. There might be some low urgency notifications that you always want to see, like audio volume and brightness notifications. Making them high urgency isn't the right thing there.
It would be better to make a rule, like the proposed skip_display_dnd
(better name yet to be proposed). You could couple it to urgency levels, but you don't have to do that.
What would be your use case of different mute levels?
My use case is the same as yours - I want at least two levels (one where most notifications like Slack, but not battery level are suppressed, and one where everything is suppressed). However, I feel like having two separate modes that do mostly the same thing (dnd and pause) causes confusion. So, just having one feature with multiple levels seems simpler to me. And since pause is already there, adding levels to pause makes the most sense.
What if we keep the set-pause-level
from my idea and then add extra override-pause-level
(better name suggestions are welcome)? So we keep the multi-level nature, but do not couple it to urgency, like you mentioned.
Both of those properties would be just an integer, so user can set as many levels as he/she wanted. For example, when set-pause-level 10
is used, only notifications with override-pause-level
>= 10 would be shown.
Additionally, this brings a benefit of being able to define multiple levels of notification muting. I don't have a definite idea on what use case could this bring, but here is a quick brainstorm off the top of my head:
- pause level 4 - no notifications, used for lockscreen
- pause level 3 - only most pressing notifications (such as from battery and calendar), used for presentations and movie watching
- pause level 2 - some chat notifications allowed (such as direct slack messages), used for heavily focused work
- pause level 1 - more chat notifications allowed (such as also channel slack messages), used for lightly focused work
- pause level 0 - everything allowed
Here's my workaround for a missing do not disturb mode:
Add one or more rules like this:
[dnd]
appname = "Google Chrome"
skip_display = true
Just after starting dunst
, execute: dunstctl rule dnd disable
Then you can enable and disable dnd mode using these bash functions:
function dunst_show_history() {
hist_size=$(dunstctl history | jq '.data[0] | length')
for i in `seq $hist_size`; do
dunstctl history-pop
done
}
function dunst_dnd_stop() {
dunstctl rule dnd disable
dunst_show_history
}
function dunst_dnd_start() {
dunstctl history-clear
dunstctl rule dnd enable
}
It's not perfect, but quite flexible and
- no message is lost and
- notifications like 'Battery low' are still displayed