refactor(theme): centralize theme-related code in komorebi-themes

Getting tired of making little changes in both this and the komorebi for
Mac repo - I think eventually either komorebi-themes will live in its
own repo or komorebi for Mac will be integrated here.

But for now, at least everything is defined in komorebi-themes and I
don't have to redefine any theme-related stuff in komorebi for Mac.
This commit is contained in:
LGUG2Z
2025-12-27 21:58:37 -08:00
parent f77a303b30
commit 0758c7d900
8 changed files with 1258 additions and 1113 deletions

View File

@@ -55,6 +55,9 @@ use komorebi_client::SocketMessage;
use komorebi_client::VirtualDesktopNotification;
use komorebi_themes::Base16Wrapper;
use komorebi_themes::Catppuccin;
use komorebi_themes::KomobarThemeBase16;
use komorebi_themes::KomobarThemeCatppuccin;
use komorebi_themes::KomobarThemeCustom;
use komorebi_themes::catppuccin_egui;
use lazy_static::lazy_static;
use parking_lot::Mutex;
@@ -183,12 +186,12 @@ pub fn apply_theme(
render_config: Rc<RefCell<RenderConfig>>,
) {
let (auto_select_fill, auto_select_text) = match theme {
KomobarTheme::Catppuccin {
KomobarTheme::Catppuccin(KomobarThemeCatppuccin {
name: catppuccin,
accent: catppuccin_value,
auto_select_fill: catppuccin_auto_select_fill,
auto_select_text: catppuccin_auto_select_text,
} => {
}) => {
match catppuccin {
Catppuccin::Frappe => {
catppuccin_egui::set_theme(ctx, catppuccin_egui::FRAPPE);
@@ -253,12 +256,12 @@ pub fn apply_theme(
catppuccin_auto_select_text.map(|c| c.color32(catppuccin.as_theme())),
)
}
KomobarTheme::Base16 {
KomobarTheme::Base16(KomobarThemeBase16 {
name: base16,
accent: base16_value,
auto_select_fill: base16_auto_select_fill,
auto_select_text: base16_auto_select_text,
} => {
}) => {
ctx.set_style(base16.style());
let base16_value = base16_value.unwrap_or_default();
let accent = base16_value.color32(Base16Wrapper::Base16(base16));
@@ -276,12 +279,12 @@ pub fn apply_theme(
base16_auto_select_text.map(|c| c.color32(Base16Wrapper::Base16(base16))),
)
}
KomobarTheme::Custom {
KomobarTheme::Custom(KomobarThemeCustom {
colours,
accent: base16_value,
auto_select_fill: base16_auto_select_fill,
auto_select_text: base16_auto_select_text,
} => {
}) => {
let background = colours.background();
ctx.set_style(colours.style());
let base16_value = base16_value.unwrap_or_default();

View File

@@ -5,7 +5,6 @@ use crate::widgets::widget::WidgetConfig;
use eframe::egui::Pos2;
use eframe::egui::TextBuffer;
use eframe::egui::Vec2;
use komorebi_client::KomorebiTheme;
use komorebi_client::PathExt;
use komorebi_client::Rect;
use komorebi_client::SocketMessage;
@@ -565,81 +564,7 @@ impl From<Position> for Pos2 {
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "palette")]
/// Komorebi bar theme
pub enum KomobarTheme {
/// Theme from catppuccin-egui
#[cfg_attr(feature = "schemars", schemars(title = "Catppuccin"))]
Catppuccin {
/// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)
name: komorebi_themes::Catppuccin,
/// Accent colour
accent: Option<komorebi_themes::CatppuccinValue>,
/// Auto select fill colour
auto_select_fill: Option<komorebi_themes::CatppuccinValue>,
/// Auto select text colour
auto_select_text: Option<komorebi_themes::CatppuccinValue>,
},
/// Theme from base16-egui-themes
#[cfg_attr(feature = "schemars", schemars(title = "Base16"))]
Base16 {
/// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)
name: komorebi_themes::Base16,
/// Accent colour
accent: Option<komorebi_themes::Base16Value>,
/// Auto select fill colour
auto_select_fill: Option<komorebi_themes::Base16Value>,
/// Auto select text colour
auto_select_text: Option<komorebi_themes::Base16Value>,
},
/// Custom Base16 theme
#[cfg_attr(feature = "schemars", schemars(title = "Custom"))]
Custom {
/// Colours of the custom Base16 theme palette
colours: Box<komorebi_themes::Base16ColourPalette>,
/// Accent colour
accent: Option<komorebi_themes::Base16Value>,
/// Auto select fill colour
auto_select_fill: Option<komorebi_themes::Base16Value>,
/// Auto select text colour
auto_select_text: Option<komorebi_themes::Base16Value>,
},
}
impl From<KomorebiTheme> for KomobarTheme {
fn from(value: KomorebiTheme) -> Self {
match value {
KomorebiTheme::Catppuccin {
name, bar_accent, ..
} => Self::Catppuccin {
name,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
},
KomorebiTheme::Base16 {
name, bar_accent, ..
} => Self::Base16 {
name,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
},
KomorebiTheme::Custom {
colours,
bar_accent,
..
} => Self::Custom {
colours,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
},
}
}
}
pub use komorebi_themes::KomobarTheme;
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]

View File

@@ -429,3 +429,275 @@ impl CatppuccinValue {
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Theme from catppuccin-egui
pub struct KomorebiThemeCatppuccin {
/// Name of the Catppuccin theme (previews: https://github.com/catppuccin/catppuccin)
pub name: Catppuccin,
/// Single window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Blue)))]
pub single_border: Option<CatppuccinValue>,
/// Stack window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Green)))]
pub stack_border: Option<CatppuccinValue>,
/// Monocle window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Pink)))]
pub monocle_border: Option<CatppuccinValue>,
/// Floating window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Yellow)))]
pub floating_border: Option<CatppuccinValue>,
/// Unfocused window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Base)))]
pub unfocused_border: Option<CatppuccinValue>,
/// Unfocused locked window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Red)))]
pub unfocused_locked_border: Option<CatppuccinValue>,
#[cfg(target_os = "windows")]
/// Stackbar focused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Green)))]
pub stackbar_focused_text: Option<CatppuccinValue>,
#[cfg(target_os = "windows")]
/// Stackbar unfocused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Text)))]
pub stackbar_unfocused_text: Option<CatppuccinValue>,
#[cfg(target_os = "windows")]
/// Stackbar background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Base)))]
pub stackbar_background: Option<CatppuccinValue>,
/// Bar accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Blue)))]
pub bar_accent: Option<CatppuccinValue>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Theme from base16-egui-themes
pub struct KomorebiThemeBase16 {
/// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)
pub name: Base16,
/// Single window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0D)))]
pub single_border: Option<Base16Value>,
/// Stack window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0B)))]
pub stack_border: Option<Base16Value>,
/// Monocle window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0F)))]
pub monocle_border: Option<Base16Value>,
/// Floating window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base09)))]
pub floating_border: Option<Base16Value>,
/// Unfocused window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base01)))]
pub unfocused_border: Option<Base16Value>,
/// Unfocused locked window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base08)))]
pub unfocused_locked_border: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar focused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0B)))]
pub stackbar_focused_text: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar unfocused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base05)))]
pub stackbar_unfocused_text: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base01)))]
pub stackbar_background: Option<Base16Value>,
/// Bar accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0D)))]
pub bar_accent: Option<Base16Value>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Custom Base16 theme
pub struct KomorebiThemeCustom {
/// Colours of the custom Base16 theme palette
pub colours: Box<Base16ColourPalette>,
/// Single window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0D)))]
pub single_border: Option<Base16Value>,
/// Stack window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0B)))]
pub stack_border: Option<Base16Value>,
/// Monocle window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0F)))]
pub monocle_border: Option<Base16Value>,
/// Floating window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base09)))]
pub floating_border: Option<Base16Value>,
/// Unfocused window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base01)))]
pub unfocused_border: Option<Base16Value>,
/// Unfocused locked window border colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base08)))]
pub unfocused_locked_border: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar focused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0B)))]
pub stackbar_focused_text: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar unfocused text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base05)))]
pub stackbar_unfocused_text: Option<Base16Value>,
#[cfg(target_os = "windows")]
/// Stackbar background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base01)))]
pub stackbar_background: Option<Base16Value>,
/// Bar accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0D)))]
pub bar_accent: Option<Base16Value>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(tag = "palette")]
/// Komorebi theme
pub enum KomorebiTheme {
#[cfg_attr(feature = "schemars", schemars(title = "Catppuccin"))]
/// Theme from catppuccin-egui
Catppuccin(KomorebiThemeCatppuccin),
#[cfg_attr(feature = "schemars", schemars(title = "Base16"))]
/// Theme from base16-egui-themes
Base16(KomorebiThemeBase16),
#[cfg_attr(feature = "schemars", schemars(title = "Custom"))]
/// Custom Base16 theme
Custom(KomorebiThemeCustom),
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Theme from catppuccin-egui
pub struct KomobarThemeCatppuccin {
/// Name of the Catppuccin theme (previews: https://github.com/catppuccin/catppuccin)
pub name: Catppuccin,
/// Accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Blue)))]
pub accent: Option<CatppuccinValue>,
/// Auto select fill colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_fill: Option<CatppuccinValue>,
/// Auto select text colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_text: Option<CatppuccinValue>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Theme from base16-egui-themes
pub struct KomobarThemeBase16 {
/// Name of the Base16 theme (previews: https://tinted-theming.github.io/tinted-gallery/)
pub name: Base16,
/// Accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = Base16Value::Base0D)))]
pub accent: Option<Base16Value>,
/// Auto select fill colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_fill: Option<Base16Value>,
/// Auto select text colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_text: Option<Base16Value>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
/// Theme from base16-egui-themes
pub struct KomobarThemeCustom {
/// Colours of the custom Base16 theme palette
pub colours: Box<Base16ColourPalette>,
/// Accent colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = CatppuccinValue::Blue)))]
pub accent: Option<Base16Value>,
/// Auto select fill colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_fill: Option<Base16Value>,
/// Auto select text colour
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_select_text: Option<Base16Value>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(tag = "palette")]
/// Komorebi bar theme
pub enum KomobarTheme {
#[cfg_attr(feature = "schemars", schemars(title = "Catppuccin"))]
/// Theme from catppuccin-egui
Catppuccin(KomobarThemeCatppuccin),
#[cfg_attr(feature = "schemars", schemars(title = "Base16"))]
/// Theme from base16-egui-themes
Base16(KomobarThemeBase16),
#[cfg_attr(feature = "schemars", schemars(title = "Custom"))]
/// Custom Base16 theme
Custom(KomobarThemeCustom),
}
impl From<KomorebiTheme> for KomobarTheme {
fn from(value: KomorebiTheme) -> Self {
match value {
KomorebiTheme::Catppuccin(KomorebiThemeCatppuccin {
name, bar_accent, ..
}) => Self::Catppuccin(KomobarThemeCatppuccin {
name,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
}),
KomorebiTheme::Base16(KomorebiThemeBase16 {
name, bar_accent, ..
}) => Self::Base16(KomobarThemeBase16 {
name,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
}),
KomorebiTheme::Custom(KomorebiThemeCustom {
colours,
bar_accent,
..
}) => Self::Custom(KomobarThemeCustom {
colours,
accent: bar_accent,
auto_select_fill: None,
auto_select_text: None,
}),
}
}
}

View File

@@ -679,150 +679,7 @@ pub struct AnimationsConfig {
pub fps: Option<u64>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "palette")]
/// Komorebi theme
pub enum KomorebiTheme {
/// A theme from catppuccin-egui
#[cfg_attr(feature = "schemars", schemars(title = "Catppuccin"))]
Catppuccin {
/// Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)
name: komorebi_themes::Catppuccin,
/// Border colour when the container contains a single window
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Blue)))]
single_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container contains multiple windows
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Green)))]
stack_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is in monocle mode
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Pink)))]
monocle_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the window is floating
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Yellow)))]
floating_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is unfocused
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Base)))]
unfocused_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is unfocused and locked
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Red)))]
unfocused_locked_border: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar focused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Green)))]
stackbar_focused_text: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar unfocused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Text)))]
stackbar_unfocused_text: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar tab background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Base)))]
stackbar_background: Option<komorebi_themes::CatppuccinValue>,
/// Komorebi status bar accent
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::CatppuccinValue::Blue)))]
bar_accent: Option<komorebi_themes::CatppuccinValue>,
},
/// A theme from base16-egui-themes
#[cfg_attr(feature = "schemars", schemars(title = "Base16"))]
Base16 {
/// Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)
name: komorebi_themes::Base16,
/// Border colour when the container contains a single window
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0D)))]
single_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container contains multiple windows
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0B)))]
stack_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is in monocle mode
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0F)))]
monocle_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the window is floating
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base09)))]
floating_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base01)))]
unfocused_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused and locked
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base08)))]
unfocused_locked_border: Option<komorebi_themes::Base16Value>,
/// Stackbar focused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0B)))]
stackbar_focused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar unfocused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base05)))]
stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar tab background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base01)))]
stackbar_background: Option<komorebi_themes::Base16Value>,
/// Komorebi status bar accent
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0D)))]
bar_accent: Option<komorebi_themes::Base16Value>,
},
/// A custom Base16 theme
#[cfg_attr(feature = "schemars", schemars(title = "Custom"))]
Custom {
/// Colours of the custom Base16 theme palette
colours: Box<komorebi_themes::Base16ColourPalette>,
/// Border colour when the container contains a single window
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0D)))]
single_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container contains multiple windows
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0B)))]
stack_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is in monocle mode
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0F)))]
monocle_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the window is floating
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base09)))]
floating_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base01)))]
unfocused_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused and locked
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base08)))]
unfocused_locked_border: Option<komorebi_themes::Base16Value>,
/// Stackbar focused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0B)))]
stackbar_focused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar unfocused tab text colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base05)))]
stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar tab background colour
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base01)))]
stackbar_background: Option<komorebi_themes::Base16Value>,
/// Komorebi status bar accent
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schemars", schemars(extend("default" = komorebi_themes::Base16Value::Base0D)))]
bar_accent: Option<komorebi_themes::Base16Value>,
},
}
pub use komorebi_themes::KomorebiTheme;
impl StaticConfig {
pub fn end_of_life(raw: &str) {

View File

@@ -10,6 +10,9 @@ use crossbeam_channel::Receiver;
use crossbeam_channel::Sender;
use crossbeam_utils::atomic::AtomicCell;
use komorebi_themes::Base16Wrapper;
use komorebi_themes::KomorebiThemeBase16 as Base16;
use komorebi_themes::KomorebiThemeCatppuccin as Catppuccin;
use komorebi_themes::KomorebiThemeCustom as Custom;
use komorebi_themes::colour::Colour;
use std::ops::Deref;
use std::sync::OnceLock;
@@ -84,7 +87,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_unfocused_text,
stackbar_background,
) = match theme {
KomorebiTheme::Catppuccin {
KomorebiTheme::Catppuccin(Catppuccin {
name,
single_border,
stack_border,
@@ -96,7 +99,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_unfocused_text,
stackbar_background,
..
} => {
}) => {
let single_border = single_border
.unwrap_or(komorebi_themes::CatppuccinValue::Blue)
.color32(name.as_theme());
@@ -145,7 +148,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_background,
)
}
KomorebiTheme::Base16 {
KomorebiTheme::Base16(Base16 {
name,
single_border,
stack_border,
@@ -157,7 +160,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_unfocused_text,
stackbar_background,
..
} => {
}) => {
let single_border = single_border
.unwrap_or(komorebi_themes::Base16Value::Base0D)
.color32(Base16Wrapper::Base16(*name));
@@ -206,7 +209,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_background,
)
}
KomorebiTheme::Custom {
KomorebiTheme::Custom(Custom {
colours,
single_border,
stack_border,
@@ -218,7 +221,7 @@ pub fn handle_notifications() -> color_eyre::Result<()> {
stackbar_unfocused_text,
stackbar_background,
..
} => {
}) => {
let single_border = single_border
.unwrap_or(komorebi_themes::Base16Value::Base0D)
.color32(Base16Wrapper::Custom(colours.clone()));

View File

@@ -40,6 +40,7 @@ use crate::windows_api::WindowsApi;
use color_eyre::eyre;
use color_eyre::eyre::OptionExt;
use komorebi_themes::Base16ColourPalette;
use komorebi_themes::KomorebiThemeCustom as Custom;
use serde::Deserialize;
use serde::Serialize;
use uds_windows::UnixStream;
@@ -334,7 +335,7 @@ impl Workspace {
}
if let Some(palette) = base16_palette {
let komorebi_theme = KomorebiTheme::Custom {
let komorebi_theme = KomorebiTheme::Custom(Custom {
colours: Box::new(palette),
single_border: wallpaper
.theme_options
@@ -373,7 +374,7 @@ impl Workspace {
.as_ref()
.and_then(|o| o.stackbar_background),
bar_accent: wallpaper.theme_options.as_ref().and_then(|o| o.bar_accent),
};
});
let bytes = SocketMessage::Theme(Box::new(komorebi_theme)).as_bytes()?;

File diff suppressed because it is too large Load Diff

View File

@@ -2846,423 +2846,450 @@
"oneOf": [
{
"title": "Catppuccin",
"description": "A theme from catppuccin-egui",
"description": "Theme from catppuccin-egui",
"type": "object",
"properties": {
"bar_accent": {
"description": "Komorebi status bar accent",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Blue"
},
"floating_border": {
"description": "Border colour when the window is floating",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Yellow"
},
"monocle_border": {
"description": "Border colour when the container is in monocle mode",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Pink"
},
"name": {
"description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)",
"$ref": "#/$defs/Catppuccin"
},
"palette": {
"type": "string",
"const": "Catppuccin"
},
"single_border": {
"description": "Border colour when the container contains a single window",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Blue"
},
"stack_border": {
"description": "Border colour when the container contains multiple windows",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Green"
},
"stackbar_background": {
"description": "Stackbar tab background colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Base"
},
"stackbar_focused_text": {
"description": "Stackbar focused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Green"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Text"
},
"unfocused_border": {
"description": "Border colour when the container is unfocused",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Base"
},
"unfocused_locked_border": {
"description": "Border colour when the container is unfocused and locked",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Red"
}
},
"$ref": "#/$defs/KomorebiThemeCatppuccin",
"required": [
"palette",
"name"
"palette"
]
},
{
"title": "Base16",
"description": "A theme from base16-egui-themes",
"description": "Theme from base16-egui-themes",
"type": "object",
"properties": {
"bar_accent": {
"description": "Komorebi status bar accent",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"floating_border": {
"description": "Border colour when the window is floating",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base09"
},
"monocle_border": {
"description": "Border colour when the container is in monocle mode",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0F"
},
"name": {
"description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)",
"$ref": "#/$defs/Base16"
},
"palette": {
"type": "string",
"const": "Base16"
},
"single_border": {
"description": "Border colour when the container contains a single window",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"stack_border": {
"description": "Border colour when the container contains multiple windows",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_background": {
"description": "Stackbar tab background colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"stackbar_focused_text": {
"description": "Stackbar focused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base05"
},
"unfocused_border": {
"description": "Border colour when the container is unfocused",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"unfocused_locked_border": {
"description": "Border colour when the container is unfocused and locked",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base08"
}
},
"$ref": "#/$defs/KomorebiThemeBase16",
"required": [
"palette",
"name"
"palette"
]
},
{
"title": "Custom",
"description": "A custom Base16 theme",
"description": "Custom Base16 theme",
"type": "object",
"properties": {
"bar_accent": {
"description": "Komorebi status bar accent",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"colours": {
"description": "Colours of the custom Base16 theme palette",
"$ref": "#/$defs/Base16ColourPalette"
},
"floating_border": {
"description": "Border colour when the window is floating",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base09"
},
"monocle_border": {
"description": "Border colour when the container is in monocle mode",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0F"
},
"palette": {
"type": "string",
"const": "Custom"
},
"single_border": {
"description": "Border colour when the container contains a single window",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"stack_border": {
"description": "Border colour when the container contains multiple windows",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_background": {
"description": "Stackbar tab background colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"stackbar_focused_text": {
"description": "Stackbar focused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused tab text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base05"
},
"unfocused_border": {
"description": "Border colour when the container is unfocused",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"unfocused_locked_border": {
"description": "Border colour when the container is unfocused and locked",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base08"
}
},
"$ref": "#/$defs/KomorebiThemeCustom",
"required": [
"palette",
"colours"
"palette"
]
}
]
},
"KomorebiThemeBase16": {
"description": "Theme from base16-egui-themes",
"type": "object",
"properties": {
"bar_accent": {
"description": "Bar accent colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"floating_border": {
"description": "Floating window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base09"
},
"monocle_border": {
"description": "Monocle window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0F"
},
"name": {
"description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)",
"$ref": "#/$defs/Base16"
},
"single_border": {
"description": "Single window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"stack_border": {
"description": "Stack window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_background": {
"description": "Stackbar background colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"stackbar_focused_text": {
"description": "Stackbar focused text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base05"
},
"unfocused_border": {
"description": "Unfocused window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"unfocused_locked_border": {
"description": "Unfocused locked window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base08"
}
},
"required": [
"name"
]
},
"KomorebiThemeCatppuccin": {
"description": "Theme from catppuccin-egui",
"type": "object",
"properties": {
"bar_accent": {
"description": "Bar accent colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Blue"
},
"floating_border": {
"description": "Floating window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Yellow"
},
"monocle_border": {
"description": "Monocle window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Pink"
},
"name": {
"description": "Name of the Catppuccin theme (previews: https://github.com/catppuccin/catppuccin)",
"$ref": "#/$defs/Catppuccin"
},
"single_border": {
"description": "Single window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Blue"
},
"stack_border": {
"description": "Stack window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Green"
},
"stackbar_background": {
"description": "Stackbar background colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Base"
},
"stackbar_focused_text": {
"description": "Stackbar focused text colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Green"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused text colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Text"
},
"unfocused_border": {
"description": "Unfocused window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Base"
},
"unfocused_locked_border": {
"description": "Unfocused locked window border colour",
"anyOf": [
{
"$ref": "#/$defs/CatppuccinValue"
},
{
"type": "null"
}
],
"default": "Red"
}
},
"required": [
"name"
]
},
"KomorebiThemeCustom": {
"description": "Custom Base16 theme",
"type": "object",
"properties": {
"bar_accent": {
"description": "Bar accent colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"colours": {
"description": "Colours of the custom Base16 theme palette",
"$ref": "#/$defs/Base16ColourPalette"
},
"floating_border": {
"description": "Floating window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base09"
},
"monocle_border": {
"description": "Monocle window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0F"
},
"single_border": {
"description": "Single window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0D"
},
"stack_border": {
"description": "Stack window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_background": {
"description": "Stackbar background colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"stackbar_focused_text": {
"description": "Stackbar focused text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base0B"
},
"stackbar_unfocused_text": {
"description": "Stackbar unfocused text colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base05"
},
"unfocused_border": {
"description": "Unfocused window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base01"
},
"unfocused_locked_border": {
"description": "Unfocused locked window border colour",
"anyOf": [
{
"$ref": "#/$defs/Base16Value"
},
{
"type": "null"
}
],
"default": "Base08"
}
},
"required": [
"colours"
]
},
"LayoutOptions": {
"description": "Options for specific layouts",
"type": "object",