aboutsummaryrefslogtreecommitdiff
path: root/src/socket
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket')
-rw-r--r--src/socket/mod.rs8
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 {