From 6a0b47c57e2c740ba39c8285fa6bdb06af563f1d Mon Sep 17 00:00:00 2001 From: ProtoShark Date: Mon, 24 Mar 2025 10:11:57 -0700 Subject: [PATCH] Connect to wayland socket --- Cargo.lock | 7 +++++++ src/main.rs | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..9a2927d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ChloroStart-rs" +version = "0.1.0" diff --git a/src/main.rs b/src/main.rs index e7a11a9..1964e3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,26 @@ -fn main() { - println!("Hello, world!"); +use std::{env, error::Error, os::unix::net::UnixStream}; + + +fn wl_connect() -> Result> { + let wl_sock_path: String = format!( + "{}/{}", + env::var("XDG_RUNTIME_DIR")?, + env::var("WAYLAND_DISPLAY")? + ); + let sock = UnixStream::connect(wl_sock_path)?; + + Ok(sock) +} + +fn main() ->Result<(), Box> { + + let mut wl_sock = match wl_connect() { + Ok(res) => res, + Err(err) => { + eprintln!("wl_connect failed: {}", err); + return Err(err); + } + }; + + Ok(()) }