get + front file for polybar

This commit is contained in:
Junko 2023-11-22 13:59:39 +01:00
parent dc472a929b
commit b6b72b4b5b
2 changed files with 17 additions and 1 deletions

View File

@ -205,6 +205,7 @@ fn set_member(config_path: String, tf_members: &[String]) -> Result<(), &'static
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system); let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters); pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
} }
get(config_path);
Ok(()) Ok(())
} }
@ -220,6 +221,20 @@ fn memberlist(config_path: String) {
} }
} }
fn get(config_path: String) {
let config = get_config(&config_path);
let sys = get_system(&config_path);
let f = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &sys);
let mut names = Vec::new();
for m in &f["pk"] {
names.push(String::from(&m.name));
}
let fronters = names.join(" || ");
println!("Currently fronting: {}", fronters);
let _ = fs::write(format!("{}/.front", config_path), fronters);
}
#+end_src #+end_src
***** Memberlist ***** Memberlist

View File

@ -165,6 +165,7 @@ fn set_member(config_path: String, tf_members: &[String]) -> Result<(), &'static
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system); let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters); pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
} }
get(config_path);
Ok(()) Ok(())
} }
@ -190,7 +191,7 @@ fn get(config_path: String) {
for m in &f["pk"] { for m in &f["pk"] {
names.push(String::from(&m.name)); names.push(String::from(&m.name));
} }
let fronters = names.join(" | "); let fronters = names.join(" || ");
println!("Currently fronting: {}", fronters); println!("Currently fronting: {}", fronters);
let _ = fs::write(format!("{}/.front", config_path), fronters); let _ = fs::write(format!("{}/.front", config_path), fronters);
} }