Skip to content
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

[RFC] config reload mechanism #1350

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

bynect
Copy link
Member

@bynect bynect commented May 2, 2024

I wanted to add a way to reload the config files. part of the code is taken from #968.

In respect to #968 I added the ability to pass a list of config files to use to the dbus method. If none are passed it will use the old config list.

I noticed that the cmdline parser ignores multiple -conf options (without any acknowledgment of the fact). So I changed the behavior to accept a list of files.


Summary

  • Add dbus method ConfigReload
  • Refactor cmdline parsing to account for multiple -conf values
  • Cleanup wayland output on deinit
  • Update tests and documentation
  • Add dunstctl reload and completions
  • Keep original notification state for reload

@bynect
Copy link
Member Author

bynect commented May 2, 2024

@zappolowski it seems like the ci is having a problem with arch

maybe it's https://bbs.archlinux.org/viewtopic.php?id=276422?

@bynect bynect requested review from fwsmit and zappolowski May 2, 2024 17:54
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2024

Codecov Report

Attention: Patch coverage is 36.00000% with 64 lines in your changes are missing coverage. Please review.

Project coverage is 65.75%. Comparing base (20033b8) to head (9d693f5).

Files Patch % Lines
src/dunst.c 0.00% 27 Missing ⚠️
src/wayland/wl.c 0.00% 14 Missing ⚠️
src/queues.c 0.00% 7 Missing ⚠️
src/dbus.c 14.28% 6 Missing ⚠️
src/option_parser.c 83.33% 3 Missing ⚠️
src/rules.c 0.00% 3 Missing ⚠️
src/settings.c 66.66% 3 Missing ⚠️
src/draw.c 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1350      +/-   ##
==========================================
- Coverage   66.08%   65.75%   -0.34%     
==========================================
  Files          50       50              
  Lines        8247     8293      +46     
  Branches      958      963       +5     
==========================================
+ Hits         5450     5453       +3     
- Misses       2797     2840      +43     
Flag Coverage Δ
unittests 65.75% <36.00%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bynect bynect marked this pull request as ready for review May 3, 2024 08:02
@bynect
Copy link
Member Author

bynect commented May 3, 2024

mostly done. I'll do some more checks and maybe add a functional test

main.c Outdated Show resolved Hide resolved
src/dunst.c Outdated Show resolved Hide resolved
@@ -179,6 +179,10 @@ gint64 queues_get_next_datachange(gint64 time);
*/
struct notification* queues_get_by_id(int id);

/**
* Reapply all rules to the queue (used when reloading configs)
Copy link
Member

Choose a reason for hiding this comment

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

What if a property of a notification is previously changed by a rule? Then reapplying the rule will apply to the changed notification, not the original. This might result in weird behavior. To make it work correctly you have to store the original notification's contents

Copy link
Member Author

@bynect bynect May 6, 2024

Choose a reason for hiding this comment

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

That's true, but for now I think this is the correct behavior. I also added it to the documentation. Maybe we could add an option keep_original or something to maintain a copy of the original notification if the user so wants. Doing so by default would add to the memory footprint I think

Copy link
Member

Choose a reason for hiding this comment

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

I would definitely not make an option for this. The behavior will probably be acceptable in most cases, but the more correct thing to do is store the original notification and apply the rule to that.

Say a rule matches a notification with a timeout of 10 seconds with match_dbus_timeout and sets the timeout to 20 seconds and the color to yellow. Let's say you change your config to change the color to green instead and reload. You expect the notification to become green, but it stays yellow, because it's timeout has been changed to 20, making it not match the rule anymore.

Of course this is not the end of the world, but it is not the correct behavior. I don't see many rules that would make it a very common occurrence, so it would be fine by me to keep it like this. But it would be good to document and make an issue about it, so it is not forgotten.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I already wrote it somewhere in the docs. But I can just as easily save the original state if you so want

Copy link
Member Author

Choose a reason for hiding this comment

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

@fwsmit I would prefer doing that in another pr if possible since this is already quite big. How are the current changes looking?

src/notification.c Outdated Show resolved Hide resolved
@fwsmit
Copy link
Member

fwsmit commented May 6, 2024

Thanks for picking this up! I never got it to work properly when I tried it. But when the code is structured well, it should not be too hard to implement

src/dunst.c Show resolved Hide resolved
@bynect
Copy link
Member Author

bynect commented May 7, 2024

Thanks for picking this up! I never got it to work properly when I tried it. But when the code is structured well, it should not be too hard to implement

I made some updates. The only thing I am a bit unsure is the reapply of rules

This was referenced May 22, 2024
@bynect bynect requested a review from fwsmit May 28, 2024 23:24
@bynect
Copy link
Member Author

bynect commented May 28, 2024

Basically I added a rule struct inside the notification that is allocated and filled when we try to apply a rule to change a value. Then when we reload we reapply that rule to "revert" the original state.
it should work but I haven't tested much (it is kind of involved)

@fwsmit does this solve the problem you said in the comments?

@bynect
Copy link
Member Author

bynect commented May 29, 2024

arch ci is not working ...

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.

None yet

3 participants