From 271f9de0d8f191364f28f7efe18b597c5efba9ca Mon Sep 17 00:00:00 2001 From: Luke Maxwell <24lbmaxwell@protonmail.com> Date: Tue, 23 Jun 2026 12:06:10 -0400 Subject: [PATCH 1/2] allow connection via env var --- src/wayland.rs | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/wayland.rs b/src/wayland.rs index bee5202..e362dad 100644 --- a/src/wayland.rs +++ b/src/wayland.rs @@ -1,4 +1,7 @@ +use std::{env, os::unix::net::UnixStream, path::PathBuf}; + use wayland_client::{ + backend::Backend, delegate_noop, protocol::{wl_output, wl_registry}, Connection, Dispatch, Proxy, QueueHandle, @@ -7,24 +10,55 @@ use wayland_protocols::xdg::xdg_output::zv1::client::{ zxdg_output_manager_v1::ZxdgOutputManagerV1, zxdg_output_v1, }; - #[derive(Copy, Clone, Default)] pub struct DisplaySize { pub width: i32, - pub height: i32 + pub height: i32, } #[derive(Default)] struct OutputData { wl_outputs: Vec, output_man: Option, - max_size: DisplaySize + max_size: DisplaySize, +} + +fn connect_to_wayland() -> Connection { + if let Some(socket_name) = env::var_os("EXTEST_DISPLAY").map(Into::::into) { + let socket_path = if socket_name.is_absolute() { + socket_name.clone() + } else { + let mut socket_path = env::var_os("XDG_RUNTIME_DIR") + .map(Into::::into) + .unwrap(); + if !socket_path.is_absolute() { + panic!("XDG_RUNTIME_DIR is not absolute"); + } + socket_path.push(&socket_name); + socket_path + }; + let stream = UnixStream::connect(socket_path) + .map_err(|_| { + panic!( + "Failed to connect to Wayland socket: {}", + socket_name.display() + ) + }) + .unwrap(); + let backend = Backend::connect(stream) + .map_err(|_| panic!("Failed to connect to Wayland backend")) + .unwrap(); + Connection::from_backend(backend) + } else { + // Default to standard Wayland connection if EXTEST_DISPLAY is not set + Connection::connect_to_env().unwrap() + } } /// Returns the largest dimensions of the detected monitors #[must_use] pub fn get_axes_range() -> DisplaySize { - let conn = Connection::connect_to_env().unwrap(); + let conn = connect_to_wayland(); let display = conn.display(); let mut queue = conn.new_event_queue(); let handle = queue.handle(); From 34d504977da07cec020d8ebaf03ec8ff1b0e25d4 Mon Sep 17 00:00:00 2001 From: Luke Maxwell <24lbmaxwell@protonmail.com> Date: Tue, 23 Jun 2026 12:13:03 -0400 Subject: [PATCH 2/2] document new changes --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index acc248c..45316e5 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,9 @@ The repository also comes with a script to automatically override Steam's deskto ```sh ./override_steam_desktop_file.sh ``` + +Optionally for exposing the wayland socket to specifically extest, without overriding the internal wayland session for steam (ex: using gamescope), you can use the following command: + +```sh +env EXTEST_DISPLAY=$WAYLAND_DISPLAY LD_PRELOAD=/path/to/libextest.so steam +```