diff options
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 64a3299..922fb0a 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -129,6 +129,7 @@ impl Config { config.merge_env_vars(); config.load_roles()?; config.ensure_sessions_dir()?; + config.check_term_theme()?; Ok(config) } @@ -546,9 +547,6 @@ impl Config { } fn merge_env_vars(&mut self) { - if let Ok(value) = env::var(get_env_name("light_theme")) { - set_bool(&mut self.light_theme, &value); - } if let Ok(value) = env::var("NO_COLOR") { let mut no_color = false; set_bool(&mut no_color, &value); @@ -568,6 +566,23 @@ impl Config { Ok(()) } + fn check_term_theme(&mut self) -> Result<()> { + if self.light_theme { + return Ok(()); + } + if let Ok(value) = env::var(get_env_name("light_theme")) { + set_bool(&mut self.light_theme, &value); + return Ok(()); + } + #[cfg(not(target_os = "windows"))] + if let Ok(crate::utils::termbg::Theme::Light) = + crate::utils::termbg::theme(std::time::Duration::from_millis(200)) + { + self.light_theme = true; + } + Ok(()) + } + fn compat_old_config(&mut self, config_path: &PathBuf) -> Result<()> { let content = read_to_string(config_path)?; let value: serde_json::Value = serde_yaml::from_str(&content)?; |
