Thomas Dy 9 жил өмнө
parent
commit
857257cd3d
2 өөрчлөгдсөн 19 нэмэгдсэн , 12 устгасан
  1. 15 8
      src/bar.rs
  2. 4 4
      src/main.rs

+ 15 - 8
src/bar.rs

@@ -1,3 +1,4 @@
+use config::Config;
 use std::io::Write;
 use std::process::{ChildStdin, Command, Stdio};
 
@@ -6,18 +7,24 @@ pub struct Bar {
 }
 
 impl Bar {
-    pub fn new(top: bool) -> Bar {
+    pub fn new(top: bool, cfg: &Config) -> Bar {
+        let val = cfg.lookup("bar.fonts").unwrap();
+        let fonts = val.as_slice().unwrap();
+        let fonts = fonts.iter().flat_map(|elem| elem.as_str());
+
         let mut bar = Command::new("lemonbar");
+        bar.stdin(Stdio::piped());
+
         if !top {
             bar.arg("-b");
         }
-        let child = bar
-            .arg("-f")
-            .arg("Inconsolatazi4:size=12")
-            .arg("-f")
-            .arg("Ionicons:size=12")
-            .stdin(Stdio::piped())
-            .spawn()
+
+        for font in fonts {
+            bar.arg("-f");
+            bar.arg(font);
+        }
+
+        let child = bar.spawn()
             .ok()
             .expect("Failed to start lemonbar");
 

+ 4 - 4
src/main.rs

@@ -16,16 +16,16 @@ 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 cfg = Arc::new(cfg);
 
+    let mut topbar = bar::Bar::new(true, &cfg);
+    let mut botbar = bar::Bar::new(false, &cfg);
+
+    let cfg = Arc::new(cfg);
     let (tx, rx) = mpsc::channel::<Message>();
     make_thread(&tx, &cfg, external::external);
     make_thread(&tx, &cfg, sensors::sensors);
     make_thread(&tx, &cfg, netspeed::netspeed);
 
-    let mut topbar = bar::Bar::new(true);
-    let mut botbar = bar::Bar::new(false);
-
     let mut data = store::Store::new();
 
     loop {