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

Merge code for desktop notification between MacOS and Linux #438

Merged
merged 7 commits into from
May 26, 2023
Merged

Merge code for desktop notification between MacOS and Linux #438

merged 7 commits into from
May 26, 2023

Conversation

TheCactusVert
Copy link
Contributor

Linux now use the crate notify-rust. BSD could use that crate too.
For Windows we could use winrt-notification.

Standards checklist:

  • The PR title is descriptive.
  • The code compiles (cargo build)
  • The code passes rustfmt (cargo fmt)
  • The code passes clippy (cargo clippy)
  • The code passes tests (cargo test)
  • Optional: I have tested the code myself
    • I also tested that Topgrade skips the step where needed

If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.

@SteveLauC
Copy link
Member

Yes, I have been curious about why topgrade uses notify-send binary to send notifications on Linux:(

@SteveLauC
Copy link
Member

SteveLauC commented May 26, 2023

Linux now use the crate notify-rust. BSD could use that crate too.
For Windows we could use winrt-notification.

It seems that all these platforms can use notify-rust, including Windows(it uses winrt-notifycation under the hood)

I just took a look at the notify-rust API, it does differ a little bit across these platforms, but the API used by topgrade:

  1. summary()
  2. body()
  3. appname
  4. timeout()
    Are all supported on these OSes.

It would be great if we can support those BSDs and Windows through notify-rust in this PR:)

Comment on lines -97 to -106
#[cfg(target_os = "linux")]
{
if config.display_preamble() && terminal::supports_notify_send() && !config.skip_notify() {
print_warning("Due to a design issue with notify-send it could be that topgrade hangs when it's finished.
If this is the case on your system add the --skip-notify flag to the topgrade command or set skip_notify = true in the config file.
If you don't want this message to appear any longer set display_preamble = false in the config file.
For more information about this issue see https://askubuntu.com/questions/110969/notify-send-ignores-timeout and https://github.com/topgrade-rs/topgrade/issues/288.");
}
}

Copy link
Member

Choose a reason for hiding this comment

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

We can get rid of that hang issue, so great

@TheCactusVert
Copy link
Contributor Author

Great if notify-rust support all OSes, there is no need to use conditional compilation.
I have tested this PR on Linux only (x86_64 and aarch64 with and without DE). If someone could compile and test on both Windows and BSD it would be perfect :).

@SteveLauC
Copy link
Member

And before merging the PR, would u like to squash your commits? So that the commits history looks clean and self-explanatory:)

@s34m
Copy link
Member

s34m commented May 26, 2023

@SteveLauC no worries, I always squash and merge ;)

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.

3 participants