Windows: show toast notification if config reload encounters error
This gives us a way to show notifs on windows, which is a feature that isn't supported by the notify-rust crate.
This commit is contained in:
1 parent
cdfd77902a
commit
b47cd72853
2 files changed
+16
-2
No files matched your search
@@ -79,6 +79,7 @@ winapi = { version = "0.3", features = [
|
||||
"synchapi",
|
||||
"winsock2",
|
||||
]}
|
||||
winrt-notification = "0.2"
|
||||
|
||||
[target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
|
||||
fontconfig = { path = "deps/fontconfig" }
|
||||
|
||||
+15
-2
@@ -151,13 +151,14 @@ impl ConfigInner {
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
let err = err.to_string();
|
||||
log::error!("While reloading configuration: {}", err);
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
notify_rust::Notification::new()
|
||||
.summary("Wezterm Configuration")
|
||||
.body(&format!("{}", err))
|
||||
.body(&err)
|
||||
// Stay on the screen until dismissed
|
||||
.hint(notify_rust::NotificationHint::Resident(true))
|
||||
// timeout isn't respected on macos
|
||||
@@ -166,7 +167,19 @@ impl ConfigInner {
|
||||
.ok();
|
||||
}
|
||||
|
||||
self.error.replace(err.to_string());
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winrt_notification::Toast;
|
||||
|
||||
Toast::new(Toast::POWERSHELL_APP_ID)
|
||||
.title("Wezterm Configuration")
|
||||
.text1(&err)
|
||||
.duration(winrt_notification::Duration::Long)
|
||||
.show()
|
||||
.ok();
|
||||
}
|
||||
|
||||
self.error.replace(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user