fix(bar): handle komorebi theme change properly

Previously if we changed/set the theme on `komorebi.json` it would apply
that theme to the bar without taking into account the transparency
alpha, also after removing the `theme` from `komorebi.json` file it
wasn't applying the theme from the bar config. This commit fixes these
issues.
This commit is contained in:
alex-ds13
2024-12-19 16:39:35 -08:00
committed by جاد
parent 73a4df884c
commit a4128b7276
2 changed files with 36 additions and 11 deletions
+24 -2
View File
@@ -496,6 +496,8 @@ impl KomorebiNotificationState {
monitor_index: usize,
rx_gui: Receiver<komorebi_client::Notification>,
bg_color: Rc<RefCell<Color32>>,
transparency_alpha: Option<u8>,
default_theme: Option<KomobarTheme>,
) {
match rx_gui.try_recv() {
Err(error) => match error {
@@ -513,13 +515,33 @@ impl KomorebiNotificationState {
SocketMessage::ReloadStaticConfiguration(path) => {
if let Ok(config) = komorebi_client::StaticConfig::read(&path) {
if let Some(theme) = config.theme {
apply_theme(ctx, KomobarTheme::from(theme), bg_color.clone());
apply_theme(
ctx,
KomobarTheme::from(theme),
bg_color.clone(),
transparency_alpha,
);
tracing::info!("applied theme from updated komorebi.json");
} else if let Some(default_theme) = default_theme {
apply_theme(
ctx,
default_theme,
bg_color.clone(),
transparency_alpha,
);
tracing::info!("removed theme from updated komorebi.json and applied default theme");
} else {
tracing::warn!("theme was removed from updated komorebi.json but there was no default theme to apply");
}
}
}
SocketMessage::Theme(theme) => {
apply_theme(ctx, KomobarTheme::from(theme), bg_color);
apply_theme(
ctx,
KomobarTheme::from(theme),
bg_color,
transparency_alpha,
);
tracing::info!("applied theme from komorebi socket message");
}
_ => {}