Browse Source

Replace external bspwm desktop input

We no longer need to setup complicated pipe things to have usable
panels.
Thomas Dy 10 năm trước cách đây
mục cha
commit
0956e34b1c
2 tập tin đã thay đổi với 18 bổ sung5 xóa
  1. 16 3
      src/bspwm.rs
  2. 2 2
      src/main.rs

+ 16 - 3
src/external.rs → src/bspwm.rs

@@ -1,13 +1,26 @@
 use comm;
 use comm::Channel;
 use config::Config;
-use std::io;
+use std::io::prelude::*;
+use std::io::BufReader;
+use std::process::{Command, Stdio};
+
+pub fn bspwm(tx: &Channel, _cfg: &Config) {
+    let bspc = Command::new("bspc")
+        .arg("subscribe")
+        .arg("report")
+        .stdout(Stdio::piped())
+        .spawn()
+        .ok()
+        .expect("Failed to start bspc subscribe");
+
+    let stdout = bspc.stdout.unwrap();
+    let mut reader = BufReader::new(stdout);
 
-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");
+        reader.read_line(&mut line).ok().expect("Failed to read line");
         let kind = line.remove(0);
         let line = line.trim();
 

+ 2 - 2
src/main.rs

@@ -1,7 +1,7 @@
 mod sensors;
 mod comm;
 mod config;
-mod external;
+mod bspwm;
 mod bar;
 mod store;
 mod music;
@@ -23,7 +23,7 @@ fn main() {
 
     let cfg = Arc::new(cfg);
     let (tx, rx) = mpsc::channel::<Message>();
-    make_thread(&tx, &cfg, external::external);
+    make_thread(&tx, &cfg, bspwm::bspwm);
     make_thread(&tx, &cfg, sensors::sensors);
     make_thread(&tx, &cfg, music::music);
     make_thread(&tx, &cfg, wm::wm);