diff --git a/src/cli.rs b/src/cli.rs index ebb11f28..6e94634f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -176,6 +176,12 @@ pub struct RunArgs { /// which they will be tried. Multiple backends can be supplied as a comma-separated list. #[clap(value_enum, use_value_delimiter = true, long)] pub backends: Vec, + /// Override the config directory. + /// + /// If not specified, JAY_CONFIG_DIR is checked, then XDG_CONFIG_HOME/jay, then + /// ~/.config/jay. + #[clap(long, value_hint = ValueHint::DirPath)] + pub config_dir: Option, } #[derive(Args, Debug)] diff --git a/src/compositor.rs b/src/compositor.rs index 93b339bd..0a2567a1 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -226,6 +226,7 @@ fn start_compositor2( let color_manager = ColorManager::new(); let crit_ids = Rc::new(CritMatcherIds::default()); let eventfd_cache = EventfdCache::new(&ring, &engine); + let explicit_config_dir = run_args.config_dir.clone(); let state = Rc::new(State { pid, kb_ctx, @@ -305,7 +306,7 @@ fn start_compositor2( serial: Default::default(), idle_inhibitor_ids: Default::default(), run_toplevel, - config_dir: config_dir(), + config_dir: explicit_config_dir.or_else(config_dir), config_file_id: NumCell::new(1), tracker: Default::default(), data_offer_ids: Default::default(), @@ -820,6 +821,9 @@ fn create_dummy_output(state: &Rc) { } pub fn config_dir() -> Option { + if let Ok(dir) = env::var("JAY_CONFIG_DIR") { + return Some(dir); + } if let Ok(xdg) = env::var("XDG_CONFIG_HOME") { Some(format!("{}/jay", xdg)) } else if let Ok(home) = env::var("HOME") {