aboutsummaryrefslogtreecommitdiff
path: root/src/config/theme.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-18 02:52:35 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-18 02:53:31 +0300
commit36b4001f4526b60f1c9b67a4a34596e5ad2bcca1 (patch)
tree520ab28a0a3f3f798e6e655fc83529e8617720e9 /src/config/theme.rs
parentaca35ea76f3df15ec68fd07959d939f5e7a78a6c (diff)
feat: sync theme with host appearance
refs #675
Diffstat (limited to 'src/config/theme.rs')
-rw-r--r--src/config/theme.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/config/theme.rs b/src/config/theme.rs
index 87722b6e..fc601d3f 100644
--- a/src/config/theme.rs
+++ b/src/config/theme.rs
@@ -11,17 +11,23 @@ use tracing::warn;
/// accent = "#f5c2e7"
/// red = "#ff6188"
/// ```
-#[derive(Debug, Default, Deserialize)]
+#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
pub struct ThemeConfig {
/// Built-in theme name. Default: "catppuccin".
pub name: Option<String>,
+ /// Follow host terminal light/dark appearance and switch between theme names.
+ pub auto_switch: bool,
+ /// Theme name used when `auto_switch` selects a dark appearance.
+ pub dark_name: Option<String>,
+ /// Theme name used when `auto_switch` selects a light appearance.
+ pub light_name: Option<String>,
/// Custom overrides — applied on top of the selected base theme.
pub custom: Option<CustomThemeColors>,
}
/// Per-token color overrides. All fields optional — only set what you want to change.
-#[derive(Debug, Default, Deserialize)]
+#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
pub struct CustomThemeColors {
pub accent: Option<String>,
@@ -135,6 +141,22 @@ name = "dracula"
}
#[test]
+ fn theme_auto_switch_fields_parse() {
+ let toml = r#"
+[theme]
+name = "catppuccin"
+auto_switch = true
+dark_name = "tokyo-night"
+light_name = "catppuccin-latte"
+"#;
+ let config: Config = toml::from_str(toml).unwrap();
+ assert_eq!(config.theme.name.as_deref(), Some("catppuccin"));
+ assert!(config.theme.auto_switch);
+ assert_eq!(config.theme.dark_name.as_deref(), Some("tokyo-night"));
+ assert_eq!(config.theme.light_name.as_deref(), Some("catppuccin-latte"));
+ }
+
+ #[test]
fn theme_custom_overrides_parse() {
let toml = r##"
[theme]
@@ -158,6 +180,9 @@ red = "rgb(255, 85, 85)"
fn theme_defaults_when_missing() {
let config: Config = toml::from_str("").unwrap();
assert!(config.theme.name.is_none());
+ assert!(!config.theme.auto_switch);
+ assert!(config.theme.dark_name.is_none());
+ assert!(config.theme.light_name.is_none());
assert!(config.theme.custom.is_none());
}
}