|  | @@ -1,58 +1,66 @@
 | 
	
		
			
				|  |  |  extern crate xcb;
 | 
	
		
			
				|  |  | +#[macro_use]
 | 
	
		
			
				|  |  | +extern crate chan;
 | 
	
		
			
				|  |  | +extern crate chan_signal;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -mod sensors;
 | 
	
		
			
				|  |  | -mod comm;
 | 
	
		
			
				|  |  | -mod config;
 | 
	
		
			
				|  |  | -mod bspwm;
 | 
	
		
			
				|  |  | -mod bar;
 | 
	
		
			
				|  |  | -mod tray;
 | 
	
		
			
				|  |  | -mod store;
 | 
	
		
			
				|  |  | -mod music;
 | 
	
		
			
				|  |  | -mod wm;
 | 
	
		
			
				|  |  | -mod x11;
 | 
	
		
			
				|  |  | +//mod sensors;
 | 
	
		
			
				|  |  | +//mod comm;
 | 
	
		
			
				|  |  | +//mod config;
 | 
	
		
			
				|  |  | +//mod bspwm;
 | 
	
		
			
				|  |  | +//mod bar;
 | 
	
		
			
				|  |  | +//mod tray;
 | 
	
		
			
				|  |  | +//mod store;
 | 
	
		
			
				|  |  | +//mod music;
 | 
	
		
			
				|  |  | +//mod wm;
 | 
	
		
			
				|  |  | +//mod x11;
 | 
	
		
			
				|  |  | +mod ui;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -use comm::{Channel, Message};
 | 
	
		
			
				|  |  | -use config::Config;
 | 
	
		
			
				|  |  | -use std::env;
 | 
	
		
			
				|  |  | -use std::sync::Arc;
 | 
	
		
			
				|  |  | -use std::sync::mpsc;
 | 
	
		
			
				|  |  | -use std::thread;
 | 
	
		
			
				|  |  | +//use comm::{Channel, Message};
 | 
	
		
			
				|  |  | +//use config::Config;
 | 
	
		
			
				|  |  | +//use std::env;
 | 
	
		
			
				|  |  | +//use std::sync::Arc;
 | 
	
		
			
				|  |  | +//use std::sync::mpsc;
 | 
	
		
			
				|  |  | +use std::process;
 | 
	
		
			
				|  |  | +//use std::thread;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  fn main() {
 | 
	
		
			
				|  |  | -    let config_path = env::args().nth(1).unwrap_or("./panel.toml".to_string());
 | 
	
		
			
				|  |  | -    let cfg = config::load(&config_path);
 | 
	
		
			
				|  |  | +    let signal = chan_signal::notify(&[chan_signal::Signal::INT, chan_signal::Signal::TERM]);
 | 
	
		
			
				|  |  | +//    let config_path = env::args().nth(1).unwrap_or("./panel.toml".to_string());
 | 
	
		
			
				|  |  | +//    let cfg = config::load(&config_path);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//    let mut topbar = bar::Bar::new(true, &cfg);
 | 
	
		
			
				|  |  | +//    let _tray = tray::Tray::new();
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//    let cfg = Arc::new(cfg);
 | 
	
		
			
				|  |  | +//    let (tx, rx) = mpsc::channel::<Message>();
 | 
	
		
			
				|  |  | +//    make_thread(&tx, &cfg, bspwm::bspwm);
 | 
	
		
			
				|  |  | +//    make_thread(&tx, &cfg, sensors::sensors);
 | 
	
		
			
				|  |  | +//    make_thread(&tx, &cfg, music::music);
 | 
	
		
			
				|  |  | +//    make_thread(&tx, &cfg, wm::wm);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//    let mut data = store::Store::new();
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//    loop {
 | 
	
		
			
				|  |  | +//        let msg = rx.recv().unwrap();
 | 
	
		
			
				|  |  | +//        data.save(msg);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//        topbar.send(&format!("{}| {}%{{r}}{}{}",
 | 
	
		
			
				|  |  | +//            data.get("desktops"),
 | 
	
		
			
				|  |  | +//            data.get("title"),
 | 
	
		
			
				|  |  | +//            data.get("sensors"),
 | 
	
		
			
				|  |  | +//            data.get("spacer")
 | 
	
		
			
				|  |  | +//        ));
 | 
	
		
			
				|  |  | +//    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    let mut topbar = bar::Bar::new(true, &cfg);
 | 
	
		
			
				|  |  | -    let _tray = tray::Tray::new();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    let cfg = Arc::new(cfg);
 | 
	
		
			
				|  |  | -    let (tx, rx) = mpsc::channel::<Message>();
 | 
	
		
			
				|  |  | -    make_thread(&tx, &cfg, bspwm::bspwm);
 | 
	
		
			
				|  |  | -    make_thread(&tx, &cfg, sensors::sensors);
 | 
	
		
			
				|  |  | -    make_thread(&tx, &cfg, music::music);
 | 
	
		
			
				|  |  | -    make_thread(&tx, &cfg, wm::wm);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    let mut data = store::Store::new();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    loop {
 | 
	
		
			
				|  |  | -        let msg = rx.recv().unwrap();
 | 
	
		
			
				|  |  | -        data.save(msg);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        topbar.send(&format!("{}| {}%{{r}}{}{}",
 | 
	
		
			
				|  |  | -            data.get("desktops"),
 | 
	
		
			
				|  |  | -            data.get("title"),
 | 
	
		
			
				|  |  | -            data.get("sensors"),
 | 
	
		
			
				|  |  | -            data.get("spacer")
 | 
	
		
			
				|  |  | -        ));
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    process::exit(ui::ui_main(signal));
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -fn make_thread(tx: &Channel, cfg: &Arc<Config>, func: fn(&Channel, &Config) -> ()) {
 | 
	
		
			
				|  |  | -    let thread_tx = tx.clone();
 | 
	
		
			
				|  |  | -    let thread_cfg = cfg.clone();
 | 
	
		
			
				|  |  | -    thread::spawn(move || {
 | 
	
		
			
				|  |  | -        func(&thread_tx, &thread_cfg);
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +//fn make_thread(tx: &Channel, cfg: &Arc<Config>, func: fn(&Channel, &Config) -> ()) {
 | 
	
		
			
				|  |  | +//    let thread_tx = tx.clone();
 | 
	
		
			
				|  |  | +//    let thread_cfg = cfg.clone();
 | 
	
		
			
				|  |  | +//    thread::spawn(move || {
 | 
	
		
			
				|  |  | +//        func(&thread_tx, &thread_cfg);
 | 
	
		
			
				|  |  | +//    });
 | 
	
		
			
				|  |  | +//}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |