mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Remove notify-rust dependency
It uses outdated zbus.
This commit is contained in:
Generated
+79
-650
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -67,7 +67,6 @@ libdisplay-info = "0.1.0"
|
||||
log = { version = "0.4.22", features = ["max_level_trace", "release_max_level_debug"] }
|
||||
niri-config = { version = "0.1.10", path = "niri-config" }
|
||||
niri-ipc = { version = "0.1.10", path = "niri-ipc", features = ["clap"] }
|
||||
notify-rust = { version = "~4.10.0", optional = true }
|
||||
ordered-float = "4.5.0"
|
||||
pango = { version = "0.20.4", features = ["v1_44"] }
|
||||
pangocairo = "0.20.4"
|
||||
@@ -119,7 +118,7 @@ xshell = "0.2.6"
|
||||
[features]
|
||||
default = ["dbus", "systemd", "xdp-gnome-screencast"]
|
||||
# Enables D-Bus support (serve various freedesktop and GNOME interfaces, power button handling).
|
||||
dbus = ["dep:zbus", "dep:async-io", "dep:notify-rust", "dep:url"]
|
||||
dbus = ["dep:zbus", "dep:async-io", "dep:url"]
|
||||
# Enables systemd integration (global environment, apps in transient scopes).
|
||||
systemd = ["dbus"]
|
||||
# Enables screencasting support through xdg-desktop-portal-gnome.
|
||||
|
||||
+3
-1
@@ -4545,7 +4545,9 @@ impl Niri {
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
crate::utils::show_screenshot_notification(image_path);
|
||||
if let Err(err) = crate::utils::show_screenshot_notification(image_path) {
|
||||
warn!("error showing screenshot notification: {err:?}");
|
||||
}
|
||||
#[cfg(not(feature = "dbus"))]
|
||||
drop(image_path);
|
||||
});
|
||||
|
||||
+31
-11
@@ -307,20 +307,20 @@ pub fn center_preferring_top_left_in_area(
|
||||
}
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
pub fn show_screenshot_notification(image_path: Option<PathBuf>) {
|
||||
let mut notification = notify_rust::Notification::new();
|
||||
notification
|
||||
.summary("Screenshot captured")
|
||||
.body("You can paste the image from the clipboard.")
|
||||
.urgency(notify_rust::Urgency::Normal)
|
||||
.hint(notify_rust::Hint::Transient(true));
|
||||
pub fn show_screenshot_notification(image_path: Option<PathBuf>) -> anyhow::Result<()> {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use zbus::zvariant;
|
||||
|
||||
let conn = zbus::blocking::Connection::session()?;
|
||||
|
||||
// Try to add the screenshot as an image if possible.
|
||||
let mut image_url = None;
|
||||
if let Some(path) = image_path {
|
||||
match path.canonicalize() {
|
||||
Ok(path) => match url::Url::from_file_path(path) {
|
||||
Ok(url) => {
|
||||
notification.image_path(url.as_str());
|
||||
image_url = Some(url);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("error converting screenshot path to file url: {err:?}");
|
||||
@@ -332,9 +332,29 @@ pub fn show_screenshot_notification(image_path: Option<PathBuf>) {
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(err) = notification.show() {
|
||||
warn!("error showing screenshot notification: {err:?}");
|
||||
}
|
||||
let actions: &[&str] = &[];
|
||||
|
||||
conn.call_method(
|
||||
Some("org.freedesktop.Notifications"),
|
||||
"/org/freedesktop/Notifications",
|
||||
Some("org.freedesktop.Notifications"),
|
||||
"Notify",
|
||||
&(
|
||||
"niri",
|
||||
0u32,
|
||||
image_url.as_ref().map(|url| url.as_str()).unwrap_or(""),
|
||||
"Screenshot captured",
|
||||
"You can paste the image from the clipboard.",
|
||||
actions,
|
||||
HashMap::from([
|
||||
("transient", zvariant::Value::Bool(true)),
|
||||
("urgency", zvariant::Value::U8(1)),
|
||||
]),
|
||||
-1,
|
||||
),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
|
||||
Reference in New Issue
Block a user