summaryrefslogtreecommitdiff
path: root/src/socket.rs
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2015-11-22 04:02:19 -0300
committerMatias Linares <matiaslina@openmailbox.org>2015-11-22 04:02:19 -0300
commit13310ee7dce177a24252970f607c08f3d658e676 (patch)
tree225d8c3fff3f033cdd2584e408b19aade31affba /src/socket.rs
parent5da38341bc54f24c8cad41f1b63405d8cc955fe7 (diff)
downloaddotwm-13310ee7dce177a24252970f607c08f3d658e676.tar.gz
Add socket functionality.
Something simple, but it works pretty well. The mapping between the strings that comes from the socket and functions, modifiers, keys, etc. needs some rewrite because now there's a manual mapping. The autostart file shows some functionality on how it will work. Since the next_xevent is ticking on 1s, it's preferible to make the writes on the socket all together, otherwise will pass 1 sec between two calls.
Diffstat (limited to 'src/socket.rs')
-rw-r--r--src/socket.rs63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/socket.rs b/src/socket.rs
deleted file mode 100644
index b3bb9cc..0000000
--- a/src/socket.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-// See LICENSE file for copyright and license details.
-
-use std::io::{Read,Write};
-use std::sync::mpsc::{Receiver, TryRecvError};
-
-use unix_socket::UnixStream;
-
-use dotwm::DotWM;
-use command::*;
-
-#[allow(unused_variables)]
-fn handle_socket(dotwm: &mut DotWM, stream: UnixStream) {
- let mut s = stream.try_clone().unwrap();
- let mut buf = String::new();
- s.read_to_string(&mut buf).unwrap();
- println!("buf: {}", buf);
-
- let _ = write!(s, "ok");
-}
-
-#[allow(unused_variables)]
-/// Handles the configuration and returns true when we're finished.
-fn handle_configure(dotwm: &mut DotWM, s: UnixStream) -> bool {
- let mut stream = match s.try_clone() {
- Ok(s) => s,
- Err(_) => { println!("Error"); return true },
- };
-
- let mut input = String::new();
- stream.read_to_string(&mut input).unwrap();
-
- if input != "done" {
- let _ = write!(stream, "ok");
- false
- } else {
- let _ = write!(stream, "exit");
- true
- }
-}
-
-pub fn configure_wm(dotwm: &mut DotWM, rx: &Receiver<UnixStream>) {
- exec_cmd("./autostart", &[]).unwrap();
- loop {
- match rx.recv() {
- Ok(stream) => {
- if handle_configure(dotwm, stream) {
- break;
- }
- },
- Err(e) => panic!("Socket: {}", e),
- }
- }
-}
-
-pub fn listen_socket(dotwm: &mut DotWM, rx: &Receiver<UnixStream>) {
- loop {
- match rx.try_recv() {
- Ok(stream) => handle_socket(dotwm, stream) ,
- Err(TryRecvError::Empty) => break,
- Err(TryRecvError::Disconnected) => panic!("Socket disconnected"),
- }
- }
-}