From a6b024ffbc0052813d5cfd05fa2cd207d5b20c9b Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Wed, 29 Apr 2026 20:45:04 +0300 Subject: Initial commit: Rust notification badge daemon for KDE Plasma 6 Monitors D-Bus for desktop notifications and emits Unity LauncherEntry badge updates so KDE Plasma task manager shows notification counts. - Streaming dbus-monitor parser with app matching and lifecycle tracking - KWin window discovery for automatic desktop file detection - Systemd user service, Makefile install/uninstall targets - 38 tests (32 unit + 6 integration), 97% line coverage via cargo-llvm-cov - CodeScene code health: 10/10 on all source files --- src/dbus_glue.rs | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/dbus_glue.rs (limited to 'src/dbus_glue.rs') diff --git a/src/dbus_glue.rs b/src/dbus_glue.rs new file mode 100644 index 0000000..58c7651 --- /dev/null +++ b/src/dbus_glue.rs @@ -0,0 +1,77 @@ +//! Thin wrappers around `gdbus` / `Command` calls. +//! +//! These functions are excluded from code coverage because they require +//! a live D-Bus session and KDE Plasma environment. + +use std::process::Command; + +/// Emit a Unity LauncherEntry Update signal via gdbus. +pub fn emit_badge(desktop_id: &str, properties: &str) -> Result<(), String> { + let output = Command::new("gdbus") + .args([ + "emit", + "--session", + "--object-path", + "/", + "--signal", + "com.canonical.Unity.LauncherEntry.Update", + desktop_id, + properties, + ]) + .output() + .map_err(|e| e.to_string())?; + + if output.status.success() { + Ok(()) + } else { + Err(String::from_utf8_lossy(&output.stderr).trim().to_string()) + } +} + +/// Query KWin WindowsRunner for open windows. +pub fn kwin_match() -> Option { + let output = Command::new("gdbus") + .args([ + "call", + "--session", + "--dest", + "org.kde.KWin", + "--object-path", + "/WindowsRunner", + "--method", + "org.kde.krunner1.Match", + "", + ]) + .output() + .ok()?; + + if output.status.success() { + Some(String::from_utf8_lossy(&output.stdout).to_string()) + } else { + None + } +} + +/// Get window info for a specific KWin UUID. +pub fn kwin_window_info(uuid: &str) -> Option { + let output = Command::new("gdbus") + .args([ + "call", + "--session", + "--dest", + "org.kde.KWin", + "--object-path", + "/KWin", + "--method", + "org.kde.KWin.getWindowInfo", + &format!("{{{uuid}}}"), + ]) + .output() + .ok()?; + + if output.status.success() { + Some(String::from_utf8_lossy(&output.stdout).to_string()) + } else { + None + } +} -- cgit v1.2.3