diff --git a/src/config.rs b/src/config.rs index f446aa7..c2136a8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,7 +23,7 @@ use std::fs::OpenOptions; use std::io::{Read, Write}; use std::path::Path; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Config { menu: Option, format: Option, @@ -161,13 +161,13 @@ impl Config { } } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Menu { executable: Option, args: Option>, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Format { output_format: Option, workspace_format: Option, @@ -181,7 +181,7 @@ pub struct Format { fallback_icon: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] pub struct Layout { auto_tile: Option, auto_tile_min_window_width_per_output_width: Option>, diff --git a/src/demon.rs b/src/demon.rs index 15381c4..c87381a 100644 --- a/src/demon.rs +++ b/src/demon.rs @@ -29,12 +29,15 @@ use std::thread; use swayipc as s; pub fn run_demon() { + let config = config::load_config(); let extra_props: Arc>> = Arc::new(RwLock::new(HashMap::new())); + + let config_for_ev_handler = config.clone(); let extra_props_for_ev_handler = extra_props.clone(); thread::spawn(move || { - monitor_sway_events(extra_props_for_ev_handler); + monitor_sway_events(extra_props_for_ev_handler, config_for_ev_handler); }); serve_client_requests(extra_props); @@ -50,8 +53,8 @@ fn connect_and_subscribe() -> s::Fallible { pub fn monitor_sway_events( extra_props: Arc>>, + config: config::Config, ) { - let config = config::load_config(); let mut focus_counter = 0; let mut resets = 0; let max_resets = 10;