Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 71 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "waytool"
version = "0.1.0"
edition = "2024"
rust-version = "1.88"
rust-version = "1.89"
description = "Command-line automation for Wayland: keyboard and pointer input, screenshots and window control on GNOME, KDE, wlroots compositors, Hyprland and niri"
license = "Apache-2.0"
repository = "https://github.com/mx-shift/waytool"
Expand Down Expand Up @@ -31,8 +31,7 @@ wayland-protocols = { version = "0.32.13", features = ["client", "unstable", "st
wayland-protocols-misc = { version = "0.3.12", features = ["client"] }
wayland-protocols-wlr = { version = "0.3.12", features = ["client"] }
xkbcommon = { version = "0.9.0", default-features = false }
zbus = { version = "5.15.0", default-features = false, features = ["tokio", "p2p"] }
zvariant = "5"
zbus = { version = "6.0.0", default-features = false, features = ["tokio", "p2p", "proxy", "service"] }

[profile.release]
strip = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sha256sum -c --ignore-missing SHA256SUMS
gh attestation verify <file> --repo mx-shift/waytool
```

Or build from source, with Rust 1.88 or later:
Or build from source, with Rust 1.89 or later:

```
sudo dnf install pipewire-devel libxkbcommon-devel clang # Fedora
Expand Down
10 changes: 5 additions & 5 deletions src/atspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const UI_DEFAULT_DEPTH: u32 = 40;
#[derive(Clone, Debug)]
struct AccRef {
dest: String,
path: zvariant::OwnedObjectPath,
path: zbus::OwnedObjectPath,
}

/// Connect to the dedicated accessibility bus (its address comes from
Expand All @@ -46,7 +46,7 @@ pub(crate) async fn a11y_connection(session: &zbus::Connection) -> Result<zbus::
.await
.context("org.a11y.Bus.GetAddress — is the accessibility stack running?")?;
let addr: String = reply.body().deserialize()?;
zbus::connection::Builder::address(addr.as_str())?
zbus::connection::Builder::address(addr.as_str())
.build()
.await
.with_context(|| format!("connect to accessibility bus at {addr}"))
Expand All @@ -62,7 +62,7 @@ async fn acc_children(conn: &zbus::Connection, r: &AccRef) -> Result<Vec<AccRef>
&(),
)
.await?;
let kids: Vec<(String, zvariant::OwnedObjectPath)> = reply.body().deserialize()?;
let kids: Vec<(String, zbus::OwnedObjectPath)> = reply.body().deserialize()?;
Ok(kids
.into_iter()
.filter(|(_, p)| p.as_str() != "/org/a11y/atspi/null")
Expand All @@ -83,7 +83,7 @@ async fn acc_name(conn: &zbus::Connection, r: &AccRef) -> String {
match reply {
Ok(m) => m
.body()
.deserialize::<zvariant::OwnedValue>()
.deserialize::<zbus::OwnedVariant>()
.ok()
.and_then(|v| String::try_from(v).ok())
.unwrap_or_default(),
Expand Down Expand Up @@ -180,7 +180,7 @@ async fn a11y_app_pid(conn: &zbus::Connection, dest: &str) -> Option<u32> {
async fn a11y_find_apps(conn: &zbus::Connection, win: &WindowDict) -> Result<(Vec<AccRef>, bool)> {
let root = AccRef {
dest: ATSPI_ROOT_DEST.into(),
path: zvariant::OwnedObjectPath::try_from(ATSPI_ROOT_PATH)?,
path: zbus::OwnedObjectPath::try_from(ATSPI_ROOT_PATH)?,
};
let apps = acc_children(conn, &root)
.await
Expand Down
2 changes: 1 addition & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async fn remote_desktop_version(bus: &zbus::Connection) -> Result<u32> {
)
.await
.context("read the RemoteDesktop portal's version")?;
let value: zvariant::OwnedValue = reply.body().deserialize()?;
let value: zbus::OwnedVariant = reply.body().deserialize()?;
Ok(u32::try_from(value)?)
}

Expand Down
21 changes: 11 additions & 10 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ async fn session_survives(daemon: &Daemon) -> Result<bool> {
/// without reading. Best-effort: no notification server, no
/// notification.
async fn notify_reconsent(bus: &zbus::Connection, summary: &str, body: &str) {
let hints = std::collections::HashMap::<&str, zvariant::Value>::new();
let hints = std::collections::HashMap::<&str, zbus::Variant>::new();
let sent = bus
.call_method(
Some("org.freedesktop.Notifications"),
Expand Down Expand Up @@ -417,7 +417,7 @@ async fn screen_locked() -> bool {
async fn locked() -> Result<bool> {
let bus = zbus::Connection::system().await?;
let dest = "org.freedesktop.login1";
let user: zvariant::OwnedObjectPath = bus
let user: zbus::OwnedObjectPath = bus
.call_method(
Some(dest),
"/org/freedesktop/login1",
Expand All @@ -428,7 +428,7 @@ async fn screen_locked() -> bool {
.await?
.body()
.deserialize()?;
let get = |path: zvariant::OwnedObjectPath, iface: &'static str, prop: &'static str| {
let get = |path: zbus::OwnedObjectPath, iface: &'static str, prop: &'static str| {
let bus = bus.clone();
async move {
let reply = bus
Expand All @@ -440,11 +440,11 @@ async fn screen_locked() -> bool {
&(iface, prop),
)
.await?;
let value: zvariant::OwnedValue = reply.body().deserialize()?;
let value: zbus::OwnedVariant = reply.body().deserialize()?;
Ok::<_, anyhow::Error>(value)
}
};
let (_id, display): (String, zvariant::OwnedObjectPath) =
let (_id, display): (String, zbus::OwnedObjectPath) =
get(user, "org.freedesktop.login1.User", "Display")
.await?
.try_into()?;
Expand Down Expand Up @@ -1152,10 +1152,10 @@ impl Service {
/// logical coordinates, and scale.
async fn monitors(&self) -> Result<Vec<WindowDict>, Error> {
let _call = self.admit()?;
let dict = |entries: Vec<(&str, zvariant::Value)>| -> Result<WindowDict, Error> {
let dict = |entries: Vec<(&str, zbus::Variant)>| -> Result<WindowDict, Error> {
entries
.into_iter()
.map(|(k, v)| Ok((k.to_owned(), v.try_to_owned().map_err(zbus::Error::from)?)))
.map(|(k, v)| Ok((k.to_owned(), v.try_to_owned()?)))
.collect()
};
self.daemon
Expand Down Expand Up @@ -1338,10 +1338,11 @@ pub(crate) async fn serve_client<I: zbus::object_server::Interface>(
make_iface: impl FnOnce(Hangup) -> I,
) -> Result<()> {
let (hung_up, hangup) = watch::channel(false);
let stream = stream.into_std().context("the client's socket")?;
let handshake = zbus::connection::Builder::unix_stream(stream)
.server(zbus::Guid::generate())?
.server(zbus::Guid::generate())
.p2p()
.serve_at(crate::protocol::OBJECT_PATH, make_iface(Hangup(hangup)))?
.serve_at(crate::protocol::OBJECT_PATH, make_iface(Hangup(hangup)))
.build();
let conn = tokio::time::timeout(HANDSHAKE_TIMEOUT, handshake)
.await
Expand Down Expand Up @@ -1417,7 +1418,7 @@ mod tests {
tx.send(hangup).ok().unwrap();
Nothing
}));
let conn = zbus::connection::Builder::unix_stream(client)
let conn = zbus::connection::Builder::unix_stream(client.into_std().unwrap())
.p2p()
.build()
.await
Expand Down
10 changes: 5 additions & 5 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::collections::HashMap;

use anyhow::{Context, Result};
use zvariant::OwnedValue;
use zbus::OwnedVariant;

const DEST: &str = "org.gnome.Mutter.DisplayConfig";
const PATH: &str = "/org/gnome/Mutter/DisplayConfig";
Expand All @@ -25,9 +25,9 @@ type CurrentState = (
f64,
f64,
Vec<f64>,
HashMap<String, OwnedValue>,
HashMap<String, OwnedVariant>,
)>,
HashMap<String, OwnedValue>,
HashMap<String, OwnedVariant>,
)>,
Vec<(
i32,
Expand All @@ -36,9 +36,9 @@ type CurrentState = (
u32,
bool,
Vec<(String, String, String, String)>,
HashMap<String, OwnedValue>,
HashMap<String, OwnedVariant>,
)>,
HashMap<String, OwnedValue>,
HashMap<String, OwnedVariant>,
);

/// Whether GNOME lays monitors out in physical pixels ("layout-mode"
Expand Down
12 changes: 6 additions & 6 deletions src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const EXT_CALL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5);
/// installer rather than being a bare UnknownObject.
pub(crate) async fn ext_call<B, R>(proxy: &zbus::Proxy<'_>, method: &str, body: &B) -> Result<R>
where
B: serde::Serialize + zvariant::DynamicType,
R: for<'d> zvariant::DynamicDeserialize<'d>,
B: serde::Serialize + zbus::DynamicType,
R: for<'d> zbus::wire::DynamicDeserialize<'d>,
{
// gnome-shell runs these on its main thread; one that never answers
// mustn't hang the request (and the input lock it may hold).
Expand All @@ -45,8 +45,8 @@ where
EXT_CALL_TIMEOUT.as_secs()
)
})?;
call.map_err(|e| match e {
zbus::Error::MethodError(name, _, _)
call.map_err(|e| match crate::protocol::error_reply(&e) {
Some((name, _))
if [
"org.freedesktop.DBus.Error.ServiceUnknown",
"org.freedesktop.DBus.Error.UnknownObject",
Expand All @@ -57,8 +57,8 @@ where
{
anyhow!("{EXT_INTERFACE}.{method} isn't available ({name}). {EXT_NOT_FOUND_HINT}")
}
zbus::Error::MethodError(_, Some(msg), _) => anyhow!("{method}: {msg}"),
e => anyhow!("{EXT_INTERFACE}.{method} failed: {e}"),
Some((_, Some(msg))) => anyhow!("{method}: {msg}"),
_ => anyhow!("{EXT_INTERFACE}.{method} failed: {e}"),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/kwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Kwin {
)
.await
.context("serve the KWin script's object")?;
bus.request_name_with_flags(NAME, zbus::fdo::RequestNameFlags::DoNotQueue.into())
bus.request_name_with_flags(NAME, zbus::fdo::RequestNameFlags::DO_NOT_QUEUE)
.await
.with_context(|| format!("own {NAME} (is another waytool daemon running?)"))?;
Ok(Kwin {
Expand Down
Loading
Loading