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

Add reload config ability #43

Merged
merged 1 commit into from
Oct 10, 2023
Merged

Conversation

Avimitin
Copy link
Contributor

This PR implements a new IPC command to force wpaperd to reload config. The original proposal for this PR is that the file watcher does not watch the symlink content change, so if the config is symlinked to another file, wpaperd will never know the config has changed.

@danyspin97
Copy link
Owner

Thanks for the pull request Avimitin! I have looked into hotwatch and notify crates and there is an issue open for this. We can merge this as a workaround in the meanwhile and we can remove this command later.

@@ -120,6 +120,13 @@ fn handle_message(buffer: &mut String, ustream: UnixStream, wpaperd: &mut Wpaper

IpcResponse::Ok
}),

IpcMessage::ReloadConfig => {
wpaperd.reload_config().map(|_| IpcResponse::Ok)?;
Copy link
Owner

Choose a reason for hiding this comment

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

There is no need to call map here, as we don't use Result:::Ok(IpcResponse).

IpcMessage::ReloadConfig => {
wpaperd.reload_config().map(|_| IpcResponse::Ok)?;
// Force update
wpaperd.surfaces.iter_mut().for_each(|sur| sur.next_image());
Copy link
Owner

Choose a reason for hiding this comment

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

There is no need to call this function. When there is a message on the IPC, the main loop will wake up and check if the config has changed, applying all the modification needed.

Ok(config) => {
if config != *wallpaper_config {
*wallpaper_config = config;
println!("Configuration updated");
Copy link
Owner

Choose a reason for hiding this comment

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

I think it's more consistent to use the logging library here, by calling info!.

*wallpaper_config = config;
println!("Configuration updated");
} else {
println!("Configuration unchanged");
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think that we need to print this message, knowing when the configuration has changed for now should be enough.

cli/src/main.rs Outdated Show resolved Hide resolved
@Avimitin
Copy link
Contributor Author

I've force push new changed, please review the code again. Besides those requested changes, I've also add a new function to WallpaperConfig to compare config by options, instead of the whole struct. Without this change the configuration can be different every time after we load the new configuration.

daemon/src/wallpaper_config.rs Outdated Show resolved Hide resolved
@danyspin97 danyspin97 merged commit 94023bf into danyspin97:main Oct 10, 2023
@danyspin97
Copy link
Owner

Thank you for the PR!

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