mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-18 06:50:01 +02:00
feat(cli): read whkd config dir env in check cmd
This commit ensures that komorebic's check command will respect WHKD_CONFIG_HOME when looking for whkdrc if it has been set by the user. resolve #649
This commit is contained in:
@@ -76,6 +76,26 @@ lazy_static! {
|
||||
static ref DATA_DIR: PathBuf = dirs::data_local_dir()
|
||||
.expect("there is no local data directory")
|
||||
.join("komorebi");
|
||||
static ref WHKD_CONFIG_DIR: PathBuf = {
|
||||
std::env::var("WHKD_CONFIG_HOME").map_or_else(
|
||||
|_| {
|
||||
dirs::home_dir()
|
||||
.expect("there is no home directory")
|
||||
.join(".config")
|
||||
},
|
||||
|home_path| {
|
||||
let whkd_config_home = PathBuf::from(&home_path);
|
||||
|
||||
assert!(
|
||||
whkd_config_home.as_path().is_dir(),
|
||||
"$Env:WHKD_CONFIG_HOME is set to '{}', which is not a valid directory",
|
||||
whkd_config_home.to_string_lossy()
|
||||
);
|
||||
|
||||
whkd_config_home
|
||||
},
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
trait AhkLibrary {
|
||||
@@ -1293,10 +1313,7 @@ fn main() -> Result<()> {
|
||||
let static_config = HOME_DIR.join("komorebi.json");
|
||||
let config_pwsh = HOME_DIR.join("komorebi.ps1");
|
||||
let config_ahk = HOME_DIR.join("komorebi.ahk");
|
||||
let config_whkd = dirs::home_dir()
|
||||
.expect("no home dir found")
|
||||
.join(".config")
|
||||
.join("whkdrc");
|
||||
let config_whkd = WHKD_CONFIG_DIR.join("whkdrc");
|
||||
|
||||
if static_config.exists() {
|
||||
let config_source = std::fs::read_to_string(&static_config)?;
|
||||
@@ -1343,14 +1360,17 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
if config_whkd.exists() {
|
||||
println!("Found ~/.config/whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag\n");
|
||||
println!("Found {}; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag\n", config_whkd.to_string_lossy());
|
||||
} else {
|
||||
println!("No ~/.config/whkdrc found; you may not be able to control komorebi with your keyboard\n");
|
||||
}
|
||||
} else if config_pwsh.exists() {
|
||||
println!("Found komorebi.ps1; this file will be autoloaded by komorebi\n");
|
||||
if config_whkd.exists() {
|
||||
println!("Found ~/.config/whkdrc; key bindings will be loaded from here when whkd is started\n");
|
||||
println!(
|
||||
"Found {}; key bindings will be loaded from here when whkd is started\n",
|
||||
config_whkd.to_string_lossy()
|
||||
);
|
||||
} else {
|
||||
println!("No ~/.config/whkdrc found; you may not be able to control komorebi with your keyboard\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user