mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +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"] }
|
log = { version = "0.4.22", features = ["max_level_trace", "release_max_level_debug"] }
|
||||||
niri-config = { version = "0.1.10", path = "niri-config" }
|
niri-config = { version = "0.1.10", path = "niri-config" }
|
||||||
niri-ipc = { version = "0.1.10", path = "niri-ipc", features = ["clap"] }
|
niri-ipc = { version = "0.1.10", path = "niri-ipc", features = ["clap"] }
|
||||||
notify-rust = { version = "~4.10.0", optional = true }
|
|
||||||
ordered-float = "4.5.0"
|
ordered-float = "4.5.0"
|
||||||
pango = { version = "0.20.4", features = ["v1_44"] }
|
pango = { version = "0.20.4", features = ["v1_44"] }
|
||||||
pangocairo = "0.20.4"
|
pangocairo = "0.20.4"
|
||||||
@@ -119,7 +118,7 @@ xshell = "0.2.6"
|
|||||||
[features]
|
[features]
|
||||||
default = ["dbus", "systemd", "xdp-gnome-screencast"]
|
default = ["dbus", "systemd", "xdp-gnome-screencast"]
|
||||||
# Enables D-Bus support (serve various freedesktop and GNOME interfaces, power button handling).
|
# 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).
|
# Enables systemd integration (global environment, apps in transient scopes).
|
||||||
systemd = ["dbus"]
|
systemd = ["dbus"]
|
||||||
# Enables screencasting support through xdg-desktop-portal-gnome.
|
# Enables screencasting support through xdg-desktop-portal-gnome.
|
||||||
|
|||||||
+3
-1
@@ -4545,7 +4545,9 @@ impl Niri {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dbus")]
|
#[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"))]
|
#[cfg(not(feature = "dbus"))]
|
||||||
drop(image_path);
|
drop(image_path);
|
||||||
});
|
});
|
||||||
|
|||||||
+31
-11
@@ -307,20 +307,20 @@ pub fn center_preferring_top_left_in_area(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dbus")]
|
#[cfg(feature = "dbus")]
|
||||||
pub fn show_screenshot_notification(image_path: Option<PathBuf>) {
|
pub fn show_screenshot_notification(image_path: Option<PathBuf>) -> anyhow::Result<()> {
|
||||||
let mut notification = notify_rust::Notification::new();
|
use std::collections::HashMap;
|
||||||
notification
|
|
||||||
.summary("Screenshot captured")
|
use zbus::zvariant;
|
||||||
.body("You can paste the image from the clipboard.")
|
|
||||||
.urgency(notify_rust::Urgency::Normal)
|
let conn = zbus::blocking::Connection::session()?;
|
||||||
.hint(notify_rust::Hint::Transient(true));
|
|
||||||
|
|
||||||
// Try to add the screenshot as an image if possible.
|
// Try to add the screenshot as an image if possible.
|
||||||
|
let mut image_url = None;
|
||||||
if let Some(path) = image_path {
|
if let Some(path) = image_path {
|
||||||
match path.canonicalize() {
|
match path.canonicalize() {
|
||||||
Ok(path) => match url::Url::from_file_path(path) {
|
Ok(path) => match url::Url::from_file_path(path) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
notification.image_path(url.as_str());
|
image_url = Some(url);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("error converting screenshot path to file url: {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() {
|
let actions: &[&str] = &[];
|
||||||
warn!("error showing screenshot notification: {err:?}");
|
|
||||||
}
|
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)]
|
#[inline(never)]
|
||||||
|
|||||||
Reference in New Issue
Block a user