summaryrefslogtreecommitdiff
path: root/src/dbus_glue.rs
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2026-04-29 20:45:04 +0300
committerAsko Nõmm <asko@nmm.ee>2026-04-29 20:45:04 +0300
commita6b024ffbc0052813d5cfd05fa2cd207d5b20c9b (patch)
treef0c9c606888e0d3de77c3a39c2df129eae5c0072 /src/dbus_glue.rs
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
Diffstat (limited to 'src/dbus_glue.rs')
-rw-r--r--src/dbus_glue.rs77
1 files changed, 77 insertions, 0 deletions
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<String> {
+ 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<String> {
+ 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
+ }
+}