add config sourcing
This commit is contained in:
parent
e80a328381
commit
4e6e891d9b
2 changed files with 11 additions and 1 deletions
|
|
@ -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<CliBackend>,
|
||||
/// 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<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
|
|
|
|||
|
|
@ -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<State>) {
|
|||
}
|
||||
|
||||
pub fn config_dir() -> Option<String> {
|
||||
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") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue