add support for transient hints#343
Conversation
src/dbus.c
Outdated
| if (dict_value) | ||
| raw_icon = get_raw_image_from_data_hint(dict_value); | ||
|
|
||
| dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_INT32); |
There was a problem hiding this comment.
Why is transient an int? The notification spec says it should be a boolean.
There was a problem hiding this comment.
Thanks for the feedback. At first, I thought shame on me. 🙈
The value type for the hint dictionary in D-BUS is of the DBUS_TYPE_VARIANT container type. This allows different data types (string, integer, boolean, etc.) to be used for hints.
So let's look at notify-send:
[bebe:~] % notify-send asdf 'asdf asdf asdf asdf asdf asdf asdf' --hint=bool:transient:1
Invalid hint type "bool". Valid types are int, double, string and byte.
It would be stupid to require this a boolean. We have to fix upstream bugs first, if we want to stick to the standard. 🤣
I have the feeling, that the gnome devs do not even look at their own standard sometimes.
|
Some additional things that needs to be done to complete this:
|
done |
|
Wow, you're right about it not being supported by
You're also correct here, I shouldn't do PR reviews while in a hurry, sorry! Can you squash the commits before merging? |
f43bf21 to
5127c67
Compare
done. |
|
I decided to do a final check for the boolean issue, apparently this is how the transient hint needs to be specified by the notification clients so we should probably also handle booleans the same way as ints for now. And as a codestyle suggestion, it'll probably be cleaner if we make the check and assignment inline as |
5127c67 to
2e09f03
Compare
👍 I've done it.
Added support for it. |
src/dbus.c
Outdated
| */ | ||
| if((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_BOOLEAN))) | ||
| transient = g_variant_get_boolean(dict_value); | ||
| if((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_UINT32))) |
There was a problem hiding this comment.
Small nitpick, but these should probably be else ifs, I don't see any point checking the rest if one is set.
There was a problem hiding this comment.
yes. that's good. I've always wondered, why you gave me this snippet:
if ((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_UINT32)))
With else if constructs this makes totally sense.
btw: updated it.
2ae8fad to
6374d40
Compare
|
a bit off topic: I found a patch in the gnome bugtracker. |
Look like that bug isn't going to be fixed anytime soon unfortunately. Since the main selling point of dunst is customizablility we should also add a rule to be able to override the transient hint but I'm fine with merging it as-is implementing that myself if you don't want to work on this. |
I'm quoting @tsipinakis from #310:
So, what do you want? |
|
In #310 the submitter mentioned adding But I think adding it as a rule as in I already know of a few programs that I use that (albeit customizable) set the transient hint by default while I'd prefer they didn't. In that case one can easily disable that by adding [no-transient]
match_transient = true
set_transient = falsein their config file, and this still leaves it open to add more filters and restrict that to a per-app basis. |
|
I see your case. I've added rule support for transient notifications. It went easier than I thought. |
|
Some other thoughts: After adding transient support and having also a rule to modify it. Is there any reason to still have |
Not really, I'd mark it as obsolete for now but wouldn't deprecate it just yet, after cleaning up the codebase a bit one of the things I'd like to attempt is to try to move as much of the notification logic into the rule system as default rules instead of hardcoded logic, it can come in handy in that case. Additionally, I think the |
Just removing My thought was to remove the internal |
I'd argue it's best to do the opposite, as in: Remove the transient hint from the history ignore logic and instead make it so that when a transient notification comes in This has 2 main advantages: 1) users can disable transient notifications being removed from history if they want them to simply bypass the idle timeout and 2) it can be implemented using a hardcoded rule without touching the code at all. |
I don't understand this. Having the name Also in respect of #349 I would use the name transient for the options, as there is no
?
Actually after removing I guess we're talking crossover currently. I don't understand what's your intention. I added in the last two commits the bits I described in my previous comment. I hope discussion based on this is made easier. |
Looking back, you're right, I never mentioned publicly what my opinions on the rule system are and how I think it should work. Lets take the transient hint as a good example of how I see the rule system expanding. For better or for worse the notification spec leaves ambiguous what exactly hints like But, since we have a working (albeit kind-of simplistic atm) rule system we can use that to our advantage by exposing dunsts functionalities to it and letting it make the decision on how things should be handled. For example the transient hint currently ignores history and timeout, we could bury this logic somewhere inside dunsts internals or (the in my opinion better design), expose rules that allow setting which notifications bypass the timeout and history and setting a rule that enables these on transient notifications. I am not opening a separate issue on this (for now, at least) because I think this is something that needs to be done passively while the codebase is being reworked. But the design idea is definitely up to discussion and debate. |
|
So you want the to have two options: So you want to have an absolute atomic rule system? |
f126eb7 to
a10ba27
Compare
|
Just tested this, it's working as intended with the exception of the PS: Might want to improve your the commit messages a bit e.g. |
42e48f0 to
f905cf4
Compare
I've just copied your commit message now. Thanks for the link. I only browsed over it yet, but I already see, it's a must read. In general, the topic of writing good commit messages is often evaded. Thanks for the link. |
Agreed, I've been meaning to look into finding better approach for hardcoded configurations because
They are meant as an example in case anyone want to hardcode some custom rules.
Not a clue, there is only 1 uncommented rule in master, you added the second one :p
That's much better indeed, thanks for pointing it out.
No problem, might want to convert all the commits to start with a capital too, as it's the standard convention. |
Yes, this was a mistake of mine.
Did it. |
f905cf4 to
594d707
Compare
|
This is also ready to be merged but it looks like merging #351 created a conflict. Can you resolve it? |
If the transient hint is set on the notification, it should only be valid as long as it shows up. So the pushing it to the history makes no sense. As it's no problem to change this individually by the rule system, it's a sane default for history_ignore to default to the transient option.
594d707 to
289bab0
Compare
|
rebased it. |
|
This is long overdue for a merge, thanks as usual. |
This rule was added in dunst-project#343 when trying to decide what to do with transient notifications. This seemed like a good idea at the time but it ended up creating more confusion that necessary. Relevant issues: dunst-project#310, dunst-project#508
transient notifications. #310