feat(wm): implement theme manager

This commit implements the theme manager from komorebi for Windows.
Mostly a lift and shift. Might look into the wallpaper stuff next.
This commit is contained in:
LGUG2Z committed 2025-09-30 09:59:26 -07:00
1 parent 8950a32bbb
commit f4d9734655
4 files changed
+443 -154

No files matched your search

+1
View File
@@ -67,6 +67,7 @@ pub mod reaper;
pub mod skylight;
pub mod state;
pub mod static_config;
pub mod theme_manager;
pub mod window;
pub mod window_manager;
pub mod window_manager_event;
+2
View File
@@ -17,6 +17,7 @@ use komorebi::process_command::listen_for_commands;
use komorebi::process_event::listen_for_events;
use komorebi::reaper;
use komorebi::static_config::StaticConfig;
use komorebi::theme_manager;
use komorebi::window_manager::WindowManager;
use komorebi::window_manager_event_listener;
use objc2::rc::autoreleasepool;
@@ -259,6 +260,7 @@ fn main() -> eyre::Result<()> {
wm.lock().update_focused_workspace(true, true)?;
border_manager::listen_for_notifications(wm.clone(), CoreFoundationRunLoop(run_loop));
theme_manager::listen_for_notifications();
listen_for_commands(wm.clone());
listen_for_events(wm.clone());
monitor_reconciliator::listen_for_notifications(wm.clone())?;
+155 -154
View File
@@ -34,6 +34,7 @@ use crate::monitor;
use crate::monitor::Monitor;
use crate::monitor_reconciliator;
use crate::ring::Ring;
use crate::theme_manager;
use crate::window::AspectRatio;
use crate::window::PredefinedAspectRatio;
use crate::window_manager::WindowManager;
@@ -82,43 +83,43 @@ pub struct BorderColours {
pub unfocused_locked: Option<Colour>,
}
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
// pub struct ThemeOptions {
// /// Specify Light or Dark variant for theme generation (default: Dark)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub theme_variant: Option<komorebi_themes::ThemeVariant>,
// /// Border colour when the container contains a single window (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub single_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container contains multiple windows (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub stack_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is in monocle mode (default: Base0F)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub monocle_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the window is floating (default: Base09)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub floating_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub unfocused_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused and locked (default: Base08)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub unfocused_locked_border: Option<komorebi_themes::Base16Value>,
// /// Stackbar focused tab text colour (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub stackbar_focused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar unfocused tab text colour (default: Base05)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar tab background colour (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub stackbar_background: Option<komorebi_themes::Base16Value>,
// /// Komorebi status bar accent (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// pub bar_accent: Option<komorebi_themes::Base16Value>,
// }
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ThemeOptions {
/// Specify Light or Dark variant for theme generation (default: Dark)
#[serde(skip_serializing_if = "Option::is_none")]
pub theme_variant: Option<komorebi_themes::ThemeVariant>,
/// Border colour when the container contains a single window (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
pub single_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container contains multiple windows (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
pub stack_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is in monocle mode (default: Base0F)
#[serde(skip_serializing_if = "Option::is_none")]
pub monocle_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the window is floating (default: Base09)
#[serde(skip_serializing_if = "Option::is_none")]
pub floating_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
pub unfocused_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused and locked (default: Base08)
#[serde(skip_serializing_if = "Option::is_none")]
pub unfocused_locked_border: Option<komorebi_themes::Base16Value>,
/// Stackbar focused tab text colour (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
pub stackbar_focused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar unfocused tab text colour (default: Base05)
#[serde(skip_serializing_if = "Option::is_none")]
pub stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar tab background colour (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
pub stackbar_background: Option<komorebi_themes::Base16Value>,
/// Komorebi status bar accent (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
pub bar_accent: Option<komorebi_themes::Base16Value>,
}
// #[serde_with::serde_as]
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -495,9 +496,9 @@ pub struct StaticConfig {
// /// Animations configuration options
// #[serde(skip_serializing_if = "Option::is_none")]
// pub animation: Option<AnimationsConfig>,
// /// Theme configuration options
// #[serde(skip_serializing_if = "Option::is_none")]
// pub theme: Option<KomorebiTheme>,
/// Theme configuration options
#[serde(skip_serializing_if = "Option::is_none")]
pub theme: Option<KomorebiTheme>,
/// Identify applications which are slow to send initial event notifications
// #[serde(skip_serializing_if = "Option::is_none")]
// pub slow_application_identifiers: Option<Vec<MatchingRule>>,
@@ -536,116 +537,116 @@ pub struct StaticConfig {
// pub fps: Option<u64>,
// }
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
// #[serde(tag = "palette")]
// pub enum KomorebiTheme {
// /// A theme from catppuccin-egui
// 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 (default: Blue)
// #[serde(skip_serializing_if = "Option::is_none")]
// single_border: Option<komorebi_themes::CatppuccinValue>,
// /// Border colour when the container contains multiple windows (default: Green)
// #[serde(skip_serializing_if = "Option::is_none")]
// stack_border: Option<komorebi_themes::CatppuccinValue>,
// /// Border colour when the container is in monocle mode (default: Pink)
// #[serde(skip_serializing_if = "Option::is_none")]
// monocle_border: Option<komorebi_themes::CatppuccinValue>,
// /// Border colour when the window is floating (default: Yellow)
// #[serde(skip_serializing_if = "Option::is_none")]
// floating_border: Option<komorebi_themes::CatppuccinValue>,
// /// Border colour when the container is unfocused (default: Base)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_border: Option<komorebi_themes::CatppuccinValue>,
// /// Border colour when the container is unfocused and locked (default: Red)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_locked_border: Option<komorebi_themes::CatppuccinValue>,
// /// Stackbar focused tab text colour (default: Green)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_focused_text: Option<komorebi_themes::CatppuccinValue>,
// /// Stackbar unfocused tab text colour (default: Text)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_unfocused_text: Option<komorebi_themes::CatppuccinValue>,
// /// Stackbar tab background colour (default: Base)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_background: Option<komorebi_themes::CatppuccinValue>,
// /// Komorebi status bar accent (default: Blue)
// #[serde(skip_serializing_if = "Option::is_none")]
// bar_accent: Option<komorebi_themes::CatppuccinValue>,
// },
// /// A theme from base16-egui-themes
// 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 (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// single_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container contains multiple windows (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// stack_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is in monocle mode (default: Base0F)
// #[serde(skip_serializing_if = "Option::is_none")]
// monocle_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the window is floating (default: Base09)
// #[serde(skip_serializing_if = "Option::is_none")]
// floating_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused and locked (default: Base08)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_locked_border: Option<komorebi_themes::Base16Value>,
// /// Stackbar focused tab text colour (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_focused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar unfocused tab text colour (default: Base05)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar tab background colour (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_background: Option<komorebi_themes::Base16Value>,
// /// Komorebi status bar accent (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// bar_accent: Option<komorebi_themes::Base16Value>,
// },
// /// A custom Base16 theme
// Custom {
// /// Colours of the custom Base16 theme palette
// colours: Box<komorebi_themes::Base16ColourPalette>,
// /// Border colour when the container contains a single window (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// single_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container contains multiple windows (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// stack_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is in monocle mode (default: Base0F)
// #[serde(skip_serializing_if = "Option::is_none")]
// monocle_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the window is floating (default: Base09)
// #[serde(skip_serializing_if = "Option::is_none")]
// floating_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_border: Option<komorebi_themes::Base16Value>,
// /// Border colour when the container is unfocused and locked (default: Base08)
// #[serde(skip_serializing_if = "Option::is_none")]
// unfocused_locked_border: Option<komorebi_themes::Base16Value>,
// /// Stackbar focused tab text colour (default: Base0B)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_focused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar unfocused tab text colour (default: Base05)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
// /// Stackbar tab background colour (default: Base01)
// #[serde(skip_serializing_if = "Option::is_none")]
// stackbar_background: Option<komorebi_themes::Base16Value>,
// /// Komorebi status bar accent (default: Base0D)
// #[serde(skip_serializing_if = "Option::is_none")]
// bar_accent: Option<komorebi_themes::Base16Value>,
// },
// }
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "palette")]
pub enum KomorebiTheme {
/// A theme from catppuccin-egui
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 (default: Blue)
#[serde(skip_serializing_if = "Option::is_none")]
single_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container contains multiple windows (default: Green)
#[serde(skip_serializing_if = "Option::is_none")]
stack_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is in monocle mode (default: Pink)
#[serde(skip_serializing_if = "Option::is_none")]
monocle_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the window is floating (default: Yellow)
#[serde(skip_serializing_if = "Option::is_none")]
floating_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is unfocused (default: Base)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_border: Option<komorebi_themes::CatppuccinValue>,
/// Border colour when the container is unfocused and locked (default: Red)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_locked_border: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar focused tab text colour (default: Green)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_focused_text: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar unfocused tab text colour (default: Text)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_unfocused_text: Option<komorebi_themes::CatppuccinValue>,
/// Stackbar tab background colour (default: Base)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_background: Option<komorebi_themes::CatppuccinValue>,
/// Komorebi status bar accent (default: Blue)
#[serde(skip_serializing_if = "Option::is_none")]
bar_accent: Option<komorebi_themes::CatppuccinValue>,
},
/// A theme from base16-egui-themes
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 (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
single_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container contains multiple windows (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
stack_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is in monocle mode (default: Base0F)
#[serde(skip_serializing_if = "Option::is_none")]
monocle_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the window is floating (default: Base09)
#[serde(skip_serializing_if = "Option::is_none")]
floating_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused and locked (default: Base08)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_locked_border: Option<komorebi_themes::Base16Value>,
/// Stackbar focused tab text colour (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_focused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar unfocused tab text colour (default: Base05)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar tab background colour (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_background: Option<komorebi_themes::Base16Value>,
/// Komorebi status bar accent (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
bar_accent: Option<komorebi_themes::Base16Value>,
},
/// A custom Base16 theme
Custom {
/// Colours of the custom Base16 theme palette
colours: Box<komorebi_themes::Base16ColourPalette>,
/// Border colour when the container contains a single window (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
single_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container contains multiple windows (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
stack_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is in monocle mode (default: Base0F)
#[serde(skip_serializing_if = "Option::is_none")]
monocle_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the window is floating (default: Base09)
#[serde(skip_serializing_if = "Option::is_none")]
floating_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_border: Option<komorebi_themes::Base16Value>,
/// Border colour when the container is unfocused and locked (default: Base08)
#[serde(skip_serializing_if = "Option::is_none")]
unfocused_locked_border: Option<komorebi_themes::Base16Value>,
/// Stackbar focused tab text colour (default: Base0B)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_focused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar unfocused tab text colour (default: Base05)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_unfocused_text: Option<komorebi_themes::Base16Value>,
/// Stackbar tab background colour (default: Base01)
#[serde(skip_serializing_if = "Option::is_none")]
stackbar_background: Option<komorebi_themes::Base16Value>,
/// Komorebi status bar accent (default: Base0D)
#[serde(skip_serializing_if = "Option::is_none")]
bar_accent: Option<komorebi_themes::Base16Value>,
},
}
// #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
// #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
@@ -781,7 +782,7 @@ impl From<&WindowManager> for StaticConfig {
display_index_preferences: Option::from(DISPLAY_INDEX_PREFERENCES.read().clone()),
// stackbar: None,
// animation: None,
// theme: None,
theme: None,
// slow_application_compensation_time: Option::from(
// SLOW_APPLICATION_COMPENSATION_TIME.load(Ordering::SeqCst),
// ),
@@ -1041,9 +1042,9 @@ impl StaticConfig {
// }
// }
//
// if let Some(theme) = &self.theme {
// theme_manager::send_notification(theme.clone());
// }
if let Some(theme) = &self.theme {
theme_manager::send_notification(theme.clone());
}
if let Some(path) = &self.app_specific_configuration_path {
match path {
+285
View File
@@ -0,0 +1,285 @@
#![deny(clippy::unwrap_used, clippy::expect_used)]
use crate::border_manager;
use crate::static_config::KomorebiTheme;
use crossbeam_channel::Receiver;
use crossbeam_channel::Sender;
use crossbeam_utils::atomic::AtomicCell;
use komorebi_themes::Base16Wrapper;
use komorebi_themes::colour::Colour;
use std::ops::Deref;
use std::sync::OnceLock;
use std::sync::atomic::Ordering;
pub struct Notification(KomorebiTheme);
pub static CURRENT_THEME: AtomicCell<Option<KomorebiTheme>> = AtomicCell::new(None);
impl Deref for Notification {
type Target = KomorebiTheme;
fn deref(&self) -> &Self::Target {
&self.0
}
}
static CHANNEL: OnceLock<(Sender<Notification>, Receiver<Notification>)> = OnceLock::new();
pub fn channel() -> &'static (Sender<Notification>, Receiver<Notification>) {
CHANNEL.get_or_init(|| crossbeam_channel::bounded(20))
}
fn event_tx() -> Sender<Notification> {
channel().0.clone()
}
fn event_rx() -> Receiver<Notification> {
channel().1.clone()
}
// Currently this should only be used for async focus updates, such as
// when an animation finishes and we need to focus to set the cursor
// position if the user has mouse follows focus enabled
pub fn send_notification(theme: KomorebiTheme) {
if event_tx().try_send(Notification(theme)).is_err() {
tracing::warn!("channel is full; dropping notification")
}
}
pub fn listen_for_notifications() {
std::thread::spawn(move || {
loop {
match handle_notifications() {
Ok(()) => {
tracing::warn!("restarting finished thread");
}
Err(error) => {
tracing::warn!("restarting failed thread: {}", error);
}
}
}
});
}
pub fn handle_notifications() -> color_eyre::Result<()> {
tracing::info!("listening");
let receiver = event_rx();
for notification in receiver {
let theme = &notification.0;
let (
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
_stackbar_focused_text,
_stackbar_unfocused_text,
_stackbar_background,
) = match theme {
KomorebiTheme::Catppuccin {
name,
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
..
} => {
let single_border = single_border
.unwrap_or(komorebi_themes::CatppuccinValue::Blue)
.color32(name.as_theme());
let stack_border = stack_border
.unwrap_or(komorebi_themes::CatppuccinValue::Green)
.color32(name.as_theme());
let monocle_border = monocle_border
.unwrap_or(komorebi_themes::CatppuccinValue::Pink)
.color32(name.as_theme());
let floating_border = floating_border
.unwrap_or(komorebi_themes::CatppuccinValue::Yellow)
.color32(name.as_theme());
let unfocused_border = unfocused_border
.unwrap_or(komorebi_themes::CatppuccinValue::Base)
.color32(name.as_theme());
let unfocused_locked_border = unfocused_locked_border
.unwrap_or(komorebi_themes::CatppuccinValue::Red)
.color32(name.as_theme());
let stackbar_focused_text = stackbar_focused_text
.unwrap_or(komorebi_themes::CatppuccinValue::Green)
.color32(name.as_theme());
let stackbar_unfocused_text = stackbar_unfocused_text
.unwrap_or(komorebi_themes::CatppuccinValue::Text)
.color32(name.as_theme());
let stackbar_background = stackbar_background
.unwrap_or(komorebi_themes::CatppuccinValue::Base)
.color32(name.as_theme());
(
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
)
}
KomorebiTheme::Base16 {
name,
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
..
} => {
let single_border = single_border
.unwrap_or(komorebi_themes::Base16Value::Base0D)
.color32(Base16Wrapper::Base16(*name));
let stack_border = stack_border
.unwrap_or(komorebi_themes::Base16Value::Base0B)
.color32(Base16Wrapper::Base16(*name));
let monocle_border = monocle_border
.unwrap_or(komorebi_themes::Base16Value::Base0F)
.color32(Base16Wrapper::Base16(*name));
let unfocused_border = unfocused_border
.unwrap_or(komorebi_themes::Base16Value::Base01)
.color32(Base16Wrapper::Base16(*name));
let unfocused_locked_border = unfocused_locked_border
.unwrap_or(komorebi_themes::Base16Value::Base08)
.color32(Base16Wrapper::Base16(*name));
let floating_border = floating_border
.unwrap_or(komorebi_themes::Base16Value::Base09)
.color32(Base16Wrapper::Base16(*name));
let stackbar_focused_text = stackbar_focused_text
.unwrap_or(komorebi_themes::Base16Value::Base0B)
.color32(Base16Wrapper::Base16(*name));
let stackbar_unfocused_text = stackbar_unfocused_text
.unwrap_or(komorebi_themes::Base16Value::Base05)
.color32(Base16Wrapper::Base16(*name));
let stackbar_background = stackbar_background
.unwrap_or(komorebi_themes::Base16Value::Base01)
.color32(Base16Wrapper::Base16(*name));
(
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
)
}
KomorebiTheme::Custom {
colours,
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
..
} => {
let single_border = single_border
.unwrap_or(komorebi_themes::Base16Value::Base0D)
.color32(Base16Wrapper::Custom(colours.clone()));
let stack_border = stack_border
.unwrap_or(komorebi_themes::Base16Value::Base0B)
.color32(Base16Wrapper::Custom(colours.clone()));
let monocle_border = monocle_border
.unwrap_or(komorebi_themes::Base16Value::Base0F)
.color32(Base16Wrapper::Custom(colours.clone()));
let unfocused_border = unfocused_border
.unwrap_or(komorebi_themes::Base16Value::Base01)
.color32(Base16Wrapper::Custom(colours.clone()));
let unfocused_locked_border = unfocused_locked_border
.unwrap_or(komorebi_themes::Base16Value::Base08)
.color32(Base16Wrapper::Custom(colours.clone()));
let floating_border = floating_border
.unwrap_or(komorebi_themes::Base16Value::Base09)
.color32(Base16Wrapper::Custom(colours.clone()));
let stackbar_focused_text = stackbar_focused_text
.unwrap_or(komorebi_themes::Base16Value::Base0B)
.color32(Base16Wrapper::Custom(colours.clone()));
let stackbar_unfocused_text = stackbar_unfocused_text
.unwrap_or(komorebi_themes::Base16Value::Base05)
.color32(Base16Wrapper::Custom(colours.clone()));
let stackbar_background = stackbar_background
.unwrap_or(komorebi_themes::Base16Value::Base01)
.color32(Base16Wrapper::Custom(colours.clone()));
(
single_border,
stack_border,
monocle_border,
floating_border,
unfocused_border,
unfocused_locked_border,
stackbar_focused_text,
stackbar_unfocused_text,
stackbar_background,
)
}
};
border_manager::FOCUSED.store(u32::from(Colour::from(single_border)), Ordering::SeqCst);
border_manager::MONOCLE.store(u32::from(Colour::from(monocle_border)), Ordering::SeqCst);
border_manager::STACK.store(u32::from(Colour::from(stack_border)), Ordering::SeqCst);
border_manager::FLOATING.store(u32::from(Colour::from(floating_border)), Ordering::SeqCst);
border_manager::UNFOCUSED
.store(u32::from(Colour::from(unfocused_border)), Ordering::SeqCst);
border_manager::UNFOCUSED_LOCKED.store(
u32::from(Colour::from(unfocused_locked_border)),
Ordering::SeqCst,
);
CURRENT_THEME.store(Some(notification.0));
border_manager::destroy_all_borders()?;
}
Ok(())
}