-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dunst seems to be reusing IDs #1317
Comments
Would the least performance disrupting solution be store an array containing the used ids? |
Isn't simpler to store just the biggest used ID? Until the max is reached, at which point one would resent the max to 0. This would mean that some ids might be skipped, i.e. if right after starting the server you call As regards using an array, would a set be a better choice, considering tha the array might not be sorted? I'm assuming you mean an array where one pushes back the ids as they come. |
I also thought about storing the max, but what if someone uses values close to the max uint32? We always skip many ids and reset which is kinda weird. For the array I meant a simple int array. It should be faster than anything else (at least for normal sizes) because you don't have to hash anything (set and hashmaps are advantages for string). @zappolowski what do you think about this one? |
I would consider using Citing from DNS again (Table 1. Notification Components):
So, I'd say that a simple counter still should suffice, but we should check whether the requested |
Woooo, I missed that existing bit! |
So should we check if the given id is greater than the cureent counter and issue a warning if not? |
From my POV, there are two ways of dealing with it:
For the 2nd possibility one could also think about issuing a warning, but this might not be seen by the user depending on the configuration. Maybe it's also worth looking into other notification daemons and how they deal with this case. |
What if all possible ids have been generated? You'd start all over with an id of 1, 2, ..., but that should not invalidate all the ids, no? I mean notify-send 'hello' -p # is given id 1
notify-send 'hello' -p # is given id 2
notify-send 'hello' -p # is given id 3
notify-send 'hello' -p -r 7 # should error/warning/whatever, because we're not there yet
notify-send 'hello' -p # is given id 4
...
notify-send 'hello' -p # is given id MAXINT-1
notify-send 'hello' -p # is given id MAXINT
notify-send 'hello' -p # is given id 1
notify-send 'hello' -p # is given id 2
notify-send 'hello' -p # is given id 3
notify-send 'hello' -p -r 7 # this is now valid... or not? |
The protocol says that if a maxint number of ids is reached we are allowed to restart from zero |
It reads
so it allows to reuse ids, but it does not mandate that all existing ids are invalidated at once, does it? I mean, when you reach MAXINT, all ids are valid. I expect id=1 to refer to some very old notification, so jumping back to 1 probably makes sense. But invalidating all ids means that MAXINT is also invalidated, even if it you've maybe assigned it to a client a few seconds before, and the notification might be still visually visible, with the client trying to reuse it. |
Mmh it doesn't seem too clear, however maybe we can keep a current id and a max id to keep track of it? |
Let me clarify notify-send 'hello' -p # is given id 1 (maybe several days ago?)
notify-send 'hello' -p # is given id 2
...
notify-send 'hello' -p # is given id MAXINT-1
notify-send 'hello' -p # is given id MAXINT (3 seconds ago)
notify-send 'hello' -p # is given id 1 (ok, it was old anyway)
notify-send 'hello' -p -r MAXINT # should we consider invalid? I think we shouldn't, as it's just 3 seconds old
Yeah, I guess so. |
I consider reaching MAXINT practically impossible. If you manage to send 1k notifications per second you'd still need about 50 days to wrap around. Another point is, that dunst just keeps a limited history of notifications ( After giving some more thought, my suggestion is:
|
I hadn't thought about that either. I guess that might be a reason why the spec is not really clear about what to do? |
I, sometimes, set Snippet from my notify() {
# notify-send -t 3000 'playerchs' "$@" -h string:x-canonical-private-synchronous:playerchs
notify-send -t 3000 'playerchs' "$@" -r 1625839
} |
Issue description
It seems to me that Dunst violates the D-Bus protocol of the Desktop Notifications Specification, and specifically the part I've emphasised below:
Indeed, Dunst seems to be using an incrementing counter as suggested, but the counter will not skip the values that have been already "consumed" because some non-0
replaces_id
was passed.Indeed, if I do
to ensure that Dunst it will be started anew on next notification, and then enter
I get these outputs
where the last
5
should have been6
, to avoid reusing the5
that was explicitly provided by the 3rdnotify-send
call.Installation info
Dunst - A customizable and lightweight notification-daemon 1.10.0 (2024-02-19)
pacman -S dunst
Minimal dunstrc
The text was updated successfully, but these errors were encountered: