Upgrade zbus dependency

This commit is contained in:
Demmie 2024-05-16 22:52:43 -04:00
parent f001121d69
commit 0ae2fbc06b
No known key found for this signature in database
GPG Key ID: B06DAA3D432C6E9A
5 changed files with 411 additions and 358 deletions

739
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ wayland-protocols = { version = "0.31.0", features = ["staging", "client" ]}
wayland-protocols-plasma = { version = "0.2.0", features = ["client"] }
wayland-protocols-wlr = { version = "0.2.0", features = ["client"] }
x11rb = { version = "0.13.0", features = ["screensaver"] }
zbus = {version = "3.14.1", optional = true}
zbus = {version = "4.2.1", optional = true}
chrono = "0.4.31"
toml = "0.8.8"
dirs = "5.0.1"

View File

@ -13,7 +13,7 @@ pub struct IdleWatcher {
impl IdleWatcher {
async fn seconds_since_input(&mut self) -> anyhow::Result<u32> {
let ms = self
let ms: u64 = self
.dbus_connection
.call_method(
Some("org.gnome.Mutter.IdleMonitor"),
@ -23,7 +23,8 @@ impl IdleWatcher {
&(),
)
.await?
.body::<u64>()?;
.body()
.deserialize()?;
u32::try_from(ms / 1000).with_context(|| format!("Number {ms} is invalid"))
}
}

View File

@ -34,8 +34,9 @@ impl WindowWatcher {
match call_response {
Ok(json) => {
let json = json
.body::<String>()
let json: String = json
.body()
.deserialize()
.with_context(|| "DBus interface cannot be parsed as string")?;
serde_json::from_str(&json).with_context(|| {
format!("DBus interface org.gnome.shell.extensions.FocusedWindow returned wrong JSON: {json}")

View File

@ -12,7 +12,7 @@ use std::path::Path;
use std::sync::{mpsc::channel, Arc};
use std::thread;
use tokio::sync::Mutex;
use zbus::dbus_interface;
use zbus::interface;
use zbus::{Connection, ConnectionBuilder};
const KWIN_SCRIPT_NAME: &str = "activity_watcher";
@ -53,7 +53,8 @@ impl KWinScript {
&KWIN_SCRIPT_NAME,
)
.await?
.body::<bool>()
.body()
.deserialize()
.map_err(std::convert::Into::into)
}
@ -72,7 +73,8 @@ impl KWinScript {
&(temp_path, KWIN_SCRIPT_NAME),
)
.await?
.body::<i32>()
.body()
.deserialize()
.map_err(std::convert::Into::into)
}
@ -86,7 +88,8 @@ impl KWinScript {
&KWIN_SCRIPT_NAME,
)
.await?
.body::<bool>()
.body()
.deserialize()
.map_err(std::convert::Into::into)
}
@ -143,7 +146,8 @@ impl KWinScript {
&(),
)
.await?
.body::<String>()?;
.body()
.deserialize()?;
// find a string like "KWin version: 5.27.8" and extract the version number from it:
let version = support_information
@ -206,7 +210,7 @@ struct ActiveWindowInterface {
active_window: Arc<Mutex<ActiveWindow>>,
}
#[dbus_interface(name = "com._2e3s.Awatcher")]
#[interface(name = "com._2e3s.Awatcher")]
impl ActiveWindowInterface {
async fn notify_active_window(
&mut self,
@ -274,7 +278,7 @@ impl Watcher for WindowWatcher {
Ok(connection) => {
tx.send(None).unwrap();
loop {
connection.monitor_activity().wait();
connection.monitor_activity().await;
}
}
Err(e) => tx.send(Some(e)),