diff --git a/src/color_updates.rs b/src/color_updates.rs index f636049..0e315da 100644 --- a/src/color_updates.rs +++ b/src/color_updates.rs @@ -114,4 +114,23 @@ pub fn update_panel() -> Result<(), Box> { fs::write(&panel_path, content)?; Ok(()) +} + +pub fn update_border() -> Result<(), Box> { + + let theme_path = config::get_theme_path()?; + let border_color = config::get_base_color()?; + + let mut content = fs::read_to_string(&theme_path)?; + + let border_re = Regex::new(regex_patterns::PATTERN_BORDER_COLOR)?; + + content = border_re + .replace_all(&content, |caps: ®ex::Captures| { + caps[0].replace(&caps[1], &border_color) + }) + .to_string(); + + fs::write(&theme_path, content)?; + Ok(()) } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 36c5a34..1900270 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ mod utils; use std::error::Error; use clap::{Parser, CommandFactory}; -use crate::color_updates::{update_search_bar, update_whiskar_menu, update_panel}; +use crate::color_updates::{update_search_bar, update_whiskar_menu, update_panel, update_border}; use crate::config::create_default_config; #[derive(Parser)] @@ -27,6 +27,9 @@ struct Cli { #[arg(long)] createconfig: bool, + + #[arg(long)] + updateborder: bool } fn main() -> Result<(), Box> { let cli = Cli::parse(); @@ -54,5 +57,9 @@ fn main() -> Result<(), Box> { update_panel()?; } + if cli.updateall || cli.updateborder { + update_border()?; + } + Ok(()) } \ No newline at end of file diff --git a/src/regex_patterns.rs b/src/regex_patterns.rs index 3e7498e..3df3042 100644 --- a/src/regex_patterns.rs +++ b/src/regex_patterns.rs @@ -13,3 +13,5 @@ pub const PATTERN_PANEL_BACKGROUND_RGBA: &str = r#"\s* \s* "#; + + pub const PATTERN_BORDER_COLOR: &str = r"entry\s*\{\s*border:\s*[^;]+;\s*padding:\s*[^;]+;\s*caret-color:\s*[^;]+;\s*border-radius:\s*[^;]+;\s*transition:\s*[^;]+;\s*color:\s*[^;]+;\s*border-color:\s*([^;]+);\s*background-color:\s*[^;]+;\s*\}"; \ No newline at end of file