Skip to content

Commit 0943d86

Browse files
committed
👷 pages: refactor kwin debug console dbus call
use native dbus impl instead of depending on external dbus client
1 parent e7c6a86 commit 0943d86

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

‎src/kwin_dbus.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use anyhow::{Context, Result};
2+
use tokio::runtime::Runtime;
3+
use zbus::Connection;
4+
5+
#[zbus::proxy(interface = "org.kde.KWin", default_service = "org.kde.KWin", default_path = "/KWin")]
6+
pub trait KWin {
7+
/// showDebugConsole method
8+
#[zbus(name = "showDebugConsole")]
9+
fn show_debug_console(&self) -> zbus::Result<()>;
10+
}
11+
12+
pub fn launch_kwin_debug_window() -> Result<()> {
13+
let rt = Runtime::new().context("Failed to initialize tokio runtime")?;
14+
rt.block_on(async move {
15+
let connection = Connection::session().await?;
16+
let kwin_client = KWinProxy::new(&connection).await?;
17+
kwin_client.show_debug_console().await?;
18+
19+
anyhow::Ok(())
20+
})
21+
}

‎src/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod config;
77
mod embed_data;
88
mod gresource;
99
mod installer;
10+
mod kwin_dbus;
1011
mod localization;
1112
mod logger;
1213
mod pages;

‎src/pages.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::application_browser::ApplicationBrowser;
22
use crate::systemd_units::SystemdUnits;
33
use crate::utils::PacmanWrapper;
4-
use crate::{fl, systemd_units, utils};
4+
use crate::{fl, kwin_dbus, systemd_units, utils};
55

66
use std::boxed::Box;
77
use std::fmt::Write;
@@ -262,10 +262,9 @@ fn get_nm_connections() -> Vec<String> {
262262
}
263263

264264
fn launch_kwin_debug_window() {
265-
let _ = Exec::cmd("qdbus6")
266-
.args(&["org.kde.KWin", "/KWin", "org.kde.KWin.showDebugConsole"])
267-
.join()
268-
.unwrap();
265+
if let Err(kwin_err) = kwin_dbus::launch_kwin_debug_window() {
266+
error!("Failed to launch kwin debug window: {kwin_err}");
267+
}
269268
}
270269

271270
fn create_fixes_section(builder: &Builder) -> gtk::Box {

0 commit comments

Comments
 (0)