use crate::{config::Config, profile::{active_profile,profile_from_index}, ErrorMessage, ProfileGetCommand}; use serde_json::json; pub fn print(config: Config,info: &ProfileGetCommand) -> Result { match active_profile() { Ok(i) => { match profile_from_index(config, i) { Ok(p) => { match info { ProfileGetCommand::Json => Ok(json!(p).to_string()), ProfileGetCommand::Name => Ok(p.name), ProfileGetCommand::Icon => Ok(p.icon), } /* Ok(if monitor { let xdg_directories = BaseDirectories::new(); let config = notify::Config::default().with_compare_contents(true).with_compare_contents(true).with_poll_interval(Duration::from_secs_f32(0.5)); let (tx, rx) = std::sync::mpsc::channel(); let mut watcher = PollWatcher::new(tx, config).unwrap(); watcher.watch(xdg_directories.runtime_dir.unwrap().join("sway-profiles-rs/active-profile.json").as_path(),RecursiveMode::Recursive); for _res in rx { match info { ProfileGetCommand::Json => println!("{}",json!(p).to_string()), ProfileGetCommand::Name => println!("{}",p.name), ProfileGetCommand::Icon => println!("{}",p.icon), }; match res { Ok(event) => println!("changed: {:?}", event), Err(e) => println!("watch error: {:?}", e), }; } })*/ } Err(e) => Err(e), } }, Err(e) => Err(e), } }