1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
}
}
|