mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 13:16:39 +03:00
wezterm: x11: impl persistent_toast_notification_with_click_to_open_url
This commit is contained in:
parent
140bc6e90b
commit
c23c4a6993
@ -8,6 +8,7 @@ build = "build.rs"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
open = "1.4"
|
||||
|
||||
[target.'cfg(all(not(windows), not(target_os="macos")))'.dependencies]
|
||||
# show a notification
|
||||
@ -17,7 +18,6 @@ notify-rust = "4"
|
||||
cocoa = "0.20"
|
||||
core-foundation = "0.7"
|
||||
objc = "0.2"
|
||||
open = "1.4"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winrt-notification = "0.2"
|
||||
|
@ -7,6 +7,31 @@ pub fn persistent_toast_notification_with_click_to_open_url(title: &str, message
|
||||
macos::show_notif(title, message, Some(url));
|
||||
}
|
||||
|
||||
#[cfg(all(not(target_os = "macos"), not(windows)))]
|
||||
{
|
||||
let title = title.to_owned();
|
||||
let message = message.to_owned();
|
||||
let url = url.to_owned();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
if let Ok(notif) = notify_rust::Notification::new()
|
||||
.summary(&title)
|
||||
.body(&message)
|
||||
.icon("org.wezfurlong.wezterm")
|
||||
.hint(notify_rust::Hint::Resident(true))
|
||||
.timeout(notify_rust::Timeout::Never)
|
||||
.action("Show", "Show")
|
||||
.show()
|
||||
{
|
||||
notif.wait_for_action(move |action| {
|
||||
if action == "Show" {
|
||||
let _ = open::that(&*url);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// No impl for the other OS's at this time
|
||||
}
|
||||
|
||||
@ -18,19 +43,13 @@ pub fn persistent_toast_notification(title: &str, message: &str) {
|
||||
|
||||
#[cfg(all(not(target_os = "macos"), not(windows)))]
|
||||
{
|
||||
#[allow(unused_mut)]
|
||||
let mut notif = notify_rust::Notification::new();
|
||||
notif.summary(title).body(message);
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
// Stay on the screen until dismissed
|
||||
notif.hint(notify_rust::Hint::Resident(true));
|
||||
}
|
||||
|
||||
notif
|
||||
// timeout isn't respected on macos
|
||||
.timeout(0)
|
||||
.summary(title)
|
||||
.body(message)
|
||||
.icon("org.wezfurlong.wezterm")
|
||||
.hint(notify_rust::Hint::Resident(true))
|
||||
.timeout(notify_rust::Timeout::Never)
|
||||
.show()
|
||||
.ok();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user