Skip to content

Commit

Permalink
Implement listener construct
Browse files Browse the repository at this point in the history
  • Loading branch information
morr0ne committed Sep 16, 2024
1 parent f8d779c commit 6a140d4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/server/listener.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
io,
os::fd::FromRawFd,
path::PathBuf,
pin::Pin,
task::{Context, Poll},
Expand All @@ -20,8 +21,24 @@ pin_project! {
}

impl Listener {
pub fn new() -> Self {
todo!()
pub fn new() -> Option<Self> {
let runtime_dir: PathBuf = std::env::var("XDG_RUNTIME_DIR").ok()?.into();

for i in 1..=32u8 {
let path = runtime_dir.join(format!("wayland-{i}"));

if !path.exists() {
// FIXME: actually implement this
return Some(Self {
unix_listener: UnixListener::bind(path).ok()?,
_lock: unsafe { OwnedFd::from_raw_fd(5) },
socket_path: PathBuf::new(),
lock_path: PathBuf::new(),
});
}
}

None
}
}

Expand Down

0 comments on commit 6a140d4

Please sign in to comment.