Skip to content

add support for transient hints#343

Merged
tsipinakis merged 5 commits intodunst-project:masterfrom
bebehei:transient-notifications
Sep 7, 2017
Merged

add support for transient hints#343
tsipinakis merged 5 commits intodunst-project:masterfrom
bebehei:transient-notifications

Conversation

@bebehei
Copy link
Member

@bebehei bebehei commented Jul 23, 2017

transient notifications. #310

  • ignore notification automatically in history
  • remove notification from stack, even if X is idle.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is transient an int? The notification spec says it should be a boolean.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tsipinakis
Copy link
Member

Some additional things that needs to be done to complete this:

  • Update the history and idle_threshold documentation to mention transient notifications
  • Implement transient support into dunstify (If we're going to maintain a debug tool, might as well keep it up to date).

@bebehei
Copy link
Member Author

bebehei commented Jul 24, 2017

Implement transient support into dunstify (If we're going to maintain a debug tool, might as well keep it up to date).

dunstify supports --hints=... so there is no special support needed. Please correct me, if I'm wrong. I never used dunstify.

Update the history and idle_threshold documentation to mention transient notifications

done

@tsipinakis
Copy link
Member

Wow, you're right about it not being supported by notify-send, and even more spectacularly according to the libnotify docs boolean hints are not even supported by the notification library.

dunstify supports --hints=... so there is no special support needed. Please correct me, if I'm wrong. I never used dunstify.

You're also correct here, I shouldn't do PR reviews while in a hurry, sorry!

Can you squash the commits before merging?

@bebehei bebehei force-pushed the transient-notifications branch from f43bf21 to 5127c67 Compare July 25, 2017 08:33
@bebehei
Copy link
Member Author

bebehei commented Jul 25, 2017

Can you squash the commits before merging?

done.

@tsipinakis
Copy link
Member

tsipinakis commented Jul 25, 2017

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 if ((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_UINT32))) in this case, since triple nesting if statements hurts readability.

@bebehei bebehei force-pushed the transient-notifications branch from 5127c67 to 2e09f03 Compare July 27, 2017 13:07
@bebehei
Copy link
Member Author

bebehei commented Aug 1, 2017

And as a codestyle suggestion, it'll probably be cleaner if we make the check and assignment inline as if ((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_UINT32))) in this case, since triple nesting if statements hurts readability.

👍 I've done it.

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.

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)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick, but these should probably be else ifs, I don't see any point checking the rest if one is set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bebehei bebehei force-pushed the transient-notifications branch from 2ae8fad to 6374d40 Compare August 1, 2017 13:12
@bebehei bebehei changed the title add support for transistent hints add support for transient hints Aug 1, 2017
@bebehei
Copy link
Member Author

bebehei commented Aug 1, 2017

a bit off topic: I found a patch in the gnome bugtracker.

@tsipinakis
Copy link
Member

Reported: 2012-02-17

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.

@bebehei
Copy link
Member Author

bebehei commented Aug 1, 2017

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:

At this point having history_ignore_transient and history_ignore starts to become a case of featuritis or at least having way too many similar knobs that users would have to dig a bit to find out the difference between them.

So, what do you want?

@tsipinakis
Copy link
Member

tsipinakis commented Aug 1, 2017

In #310 the submitter mentioned adding history_ignore_transient as a global option on whether transient notifications should be ignored from history. My opinion still stands that this is a bit too specific to have as a global option.

But I think adding it as a rule as in match_transient and set_transient is reasonable since I'd expect that most, if not all the notifications attributes to be overridable via rules because that's what they were designed for.

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 = false

in their config file, and this still leaves it open to add more filters and restrict that to a per-app basis.

@bebehei
Copy link
Member Author

bebehei commented Aug 2, 2017

I see your case.

I've added rule support for transient notifications. It went easier than I thought. I may have to add docs. Edit: added docs, too.

@bebehei
Copy link
Member Author

bebehei commented Aug 2, 2017

Some other thoughts: After adding transient support and having also a rule to modify it. Is there any reason to still have history_ignore?

@tsipinakis
Copy link
Member

tsipinakis commented Aug 4, 2017

After adding transient support and having also a rule to modify it. Is there any reason to still have history_ignore?

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 set_transient and match_transient is a much better name than old_ and new_`, while that's not the naming scheme we've been using I think the current one doesn't make much sense and doesn't help to easily recognize what's a filtering rule and what's an action. See #349.

@bebehei
Copy link
Member Author

bebehei commented Aug 4, 2017

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.

Just removing history_ignore option would be stupid of course ;-)

My thought was to remove the internal history_ignore field and save the option history_ignore (if set) in the transient field and let take transient precedence.

@tsipinakis
Copy link
Member

tsipinakis commented Aug 5, 2017

My thought was to remove the internal history_ignore field and save the option history_ignore (if set) in the transient field and let take transient precedence.

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 history_ignore is set to true.

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.

@bebehei
Copy link
Member Author

bebehei commented Aug 5, 2017

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 history_ignore is set to true.

I don't understand this. Having the name history_ignore in the struct makes no sense in context of notifications, while you save the transient hint value in it.

Also in respect of #349 I would use the name transient for the options, as there is no history_ignore what you could match. You only can match the transient hint.

  1. users can disable transient notifications being removed from history if they want them to simply bypass the idle timeout

?

  1. it can be implemented using a hardcoded rule without touching the code at all.

Actually after removing history_ignore logic in the code, it's just a refactoring.


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.

@tsipinakis
Copy link
Member

I don't understand what's your intention

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 transient are supposed to do and their behaviour is entirely subjective based on the notification servers and their developers, one might think that transient should mean that it bypasses history & idle timout, another user thinks that history should contain all notifications etc.

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.

@bebehei
Copy link
Member Author

bebehei commented Aug 14, 2017

So you want the to have two options: transient and history_ignore, while transient controls, if the notification gets closed although x_is_idle() and history_ignore controls, whether the notification gets pushed onto history after it's closed?

So you want to have an absolute atomic rule system?

@bebehei bebehei force-pushed the transient-notifications branch from f126eb7 to a10ba27 Compare August 14, 2017 14:23
@tsipinakis
Copy link
Member

tsipinakis commented Aug 15, 2017

Just tested this, it's working as intended with the exception of the history_ignore default, apparently in config.def.h the default of history_ignore is false. You should change it to -1 for it to work properly.

PS: Might want to improve your the commit messages a bit e.g. adapt if/else construct to upper analogy doesn't say much, Refactor if chain to avoid nested statements is much better for example. I recommend reading this in its entirety, it's the best commit message guide I have come across.

@bebehei bebehei force-pushed the transient-notifications branch 2 times, most recently from 42e48f0 to f905cf4 Compare August 15, 2017 22:08
@bebehei
Copy link
Member Author

bebehei commented Aug 15, 2017

Just tested this, it's working as intended with the exception of the history_ignore default, apparently in config.def.h the default of history_ignore is false. You should change it to -1 for it to work properly.

  1. The part with the rules is ugly formatted.
  2. Why don't we throw out the commented rules?
  3. Why the fuck are there 2 times the exact same rules?
  4. IIUC: The rules listed in config.def.h are hard coded into dunst and always valid rules, right? If so, the stuff from f905cf4 is the wrong approach. IMHO we should put a new rule where match_transient is set to 1 and history_ignore is also set to 1.

PS: Might want to improve your the commit messages a bit e.g. adapt if/else construct to upper analogy doesn't say much, Refactor if chain to avoid nested statements is much better for example. I recommend reading this in its entirety, it's the best commit message guide I have come across.

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.

@tsipinakis
Copy link
Member

The part with the rules is ugly formatted.

Agreed, I've been meaning to look into finding better approach for hardcoded configurations because config.h is indeed quite ugly and having that many global variables starts polluting the namespace but this is out the scope of this PR.

Why don't we throw out the commented rules?

They are meant as an example in case anyone want to hardcode some custom rules.

Why the fuck are there 2 times the exact same rules?

Not a clue, there is only 1 uncommented rule in master, you added the second one :p

IIUC: The rules listed in config.def.h are hard coded into dunst and always valid rules, right? If so, the stuff from f905cf4 is the wrong approach. IMHO we should put a new rule where match_transient is set to 1 and history_ignore is also set to 1.

That's much better indeed, thanks for pointing it out.

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.

No problem, might want to convert all the commits to start with a capital too, as it's the standard convention.

@bebehei
Copy link
Member Author

bebehei commented Aug 16, 2017

Not a clue, there is only 1 uncommented rule in master, you added the second one :p

Yes, this was a mistake of mine.

IIUC: The rules listed in config.def.h are hard coded into dunst and always valid rules, right? If so, the stuff from f905cf4 is the wrong approach. IMHO we should put a new rule where match_transient is set to 1 and history_ignore is also set to 1.

That's much better indeed, thanks for pointing it out.

Did it.

@bebehei bebehei force-pushed the transient-notifications branch from f905cf4 to 594d707 Compare August 16, 2017 08:08
@tsipinakis
Copy link
Member

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.
@bebehei bebehei force-pushed the transient-notifications branch from 594d707 to 289bab0 Compare August 19, 2017 10:47
@bebehei
Copy link
Member Author

bebehei commented Aug 19, 2017

rebased it.

@tsipinakis
Copy link
Member

This is long overdue for a merge, thanks as usual.

@tsipinakis tsipinakis merged commit 16bbde5 into dunst-project:master Sep 7, 2017
@bebehei bebehei deleted the transient-notifications branch September 9, 2017 15:52
tsipinakis added a commit that referenced this pull request Apr 2, 2018
This rule was added in #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: #310, #508
karlicoss pushed a commit to karlicoss/dunst that referenced this pull request Mar 21, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants