Connect to wayland socket
This commit is contained in:
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -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"
|
||||||
27
src/main.rs
27
src/main.rs
@@ -1,3 +1,26 @@
|
|||||||
fn main() {
|
use std::{env, error::Error, os::unix::net::UnixStream};
|
||||||
println!("Hello, world!");
|
|
||||||
|
|
||||||
|
fn wl_connect() -> Result<UnixStream, Box<dyn Error>> {
|
||||||
|
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<dyn Error>> {
|
||||||
|
|
||||||
|
let mut wl_sock = match wl_connect() {
|
||||||
|
Ok(res) => res,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("wl_connect failed: {}", err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user