|  | @@ -1,64 +0,0 @@
 | 
	
		
			
				|  |  | -use comm;
 | 
	
		
			
				|  |  | -use comm::Channel;
 | 
	
		
			
				|  |  | -use config::Config;
 | 
	
		
			
				|  |  | -use std::io;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -pub fn external(tx: &Channel, _cfg: &Config) {
 | 
	
		
			
				|  |  | -    let mut line = String::new();
 | 
	
		
			
				|  |  | -    loop {
 | 
	
		
			
				|  |  | -        line.clear();
 | 
	
		
			
				|  |  | -        io::stdin().read_line(&mut line).ok().expect("Failed to read line");
 | 
	
		
			
				|  |  | -        let kind = line.remove(0);
 | 
	
		
			
				|  |  | -        let line = line.trim();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        match kind {
 | 
	
		
			
				|  |  | -            'T' => comm::send(tx, "title", line),
 | 
	
		
			
				|  |  | -            'M' => comm::send(tx, "cmus", &format!("%{{A:cmus:}}{}%{{A}}", line)),
 | 
	
		
			
				|  |  | -            'W' => comm::send(tx, "desktops", &parse_bspwm(line)),
 | 
	
		
			
				|  |  | -            _ => ()
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -fn parse_bspwm(line: &str) -> String {
 | 
	
		
			
				|  |  | -    let mut out = String::new();
 | 
	
		
			
				|  |  | -    let mut monitor_count = 0;
 | 
	
		
			
				|  |  | -    let mut monitor_selected = false;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    let elems = line.split(':');
 | 
	
		
			
				|  |  | -    for elem in elems {
 | 
	
		
			
				|  |  | -        let mut chars = elem.chars();
 | 
	
		
			
				|  |  | -        let kind = chars.next().unwrap();
 | 
	
		
			
				|  |  | -        let name = chars.collect::<String>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if kind == 'M' || kind == 'm' {
 | 
	
		
			
				|  |  | -            out = format!("{}%{{S{num}}}", out, num = monitor_count);
 | 
	
		
			
				|  |  | -            monitor_count += 1;
 | 
	
		
			
				|  |  | -            monitor_selected = kind.is_uppercase();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if kind == 'L' {
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if kind == 'G' {
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else if kind == 'T' {
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            let desktop = format!("%{{A:w{name}:}} {name} %{{A}}", name = name);
 | 
	
		
			
				|  |  | -            if kind.is_uppercase() {
 | 
	
		
			
				|  |  | -                if monitor_selected {
 | 
	
		
			
				|  |  | -                    out = format!("{}%{{B#66CC66}}{}%{{B-}}", out, desktop);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else {
 | 
	
		
			
				|  |  | -                    out = format!("{}%{{B#666666}}{}%{{B-}}", out, desktop);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else if kind == 'U' || kind == 'u' {
 | 
	
		
			
				|  |  | -                out = format!("{}%{{B#CC0033}}{}%{{B-}}", out, desktop);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else if kind == 'O' || kind == 'o' {
 | 
	
		
			
				|  |  | -                out = format!("{}{}", out, desktop);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    out
 | 
	
		
			
				|  |  | -}
 |