diff options
Diffstat (limited to 'src/socket/mod.rs')
-rw-r--r-- | src/socket/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/socket/mod.rs b/src/socket/mod.rs index 804f7ac..e260284 100644 --- a/src/socket/mod.rs +++ b/src/socket/mod.rs @@ -10,6 +10,14 @@ use unix_socket::UnixStream; use dotwm::DotWM; use command::*; +pub fn next_socket_event(rx: &Receiver<UnixStream>) -> Option<UnixStream> { + match rx.try_recv() { + Ok(stream) => Some(stream), + Err(TryRecvError::Empty) => None, + Err(TryRecvError::Disconnected) => panic!("Socket disconnected"), + } +} + /// Listen a socket parsing and executing all the commands. pub fn listen_socket(dotwm: &mut DotWM, bindings: &mut BindingHash, rx: &Receiver<UnixStream>) { loop { |