From 59e8cf6c2292fa81cd4fab0ba89ff55a5ed14e5e Mon Sep 17 00:00:00 2001 From: imgurbot12 Date: Sun, 20 Aug 2023 10:27:18 -0700 Subject: [PATCH] feat: swap css/theme uses. theme is now primary css --- other-plugins/{themes => css}/powermenu.css | 0 other-plugins/powermenu.sh | 6 +++--- rmenu-plugin/src/bin/main.rs | 6 +++--- rmenu-plugin/src/lib.rs | 2 +- rmenu/src/cli.rs | 24 ++++++++++----------- rmenu/src/gui.rs | 2 +- rmenu/src/main.rs | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) rename other-plugins/{themes => css}/powermenu.css (100%) diff --git a/other-plugins/themes/powermenu.css b/other-plugins/css/powermenu.css similarity index 100% rename from other-plugins/themes/powermenu.css rename to other-plugins/css/powermenu.css diff --git a/other-plugins/powermenu.sh b/other-plugins/powermenu.sh index 5565194..fdc723d 100755 --- a/other-plugins/powermenu.sh +++ b/other-plugins/powermenu.sh @@ -1,13 +1,13 @@ #!/bin/sh +CSS=`realpath "$(dirname $0)/css/powermenu.css"` SELF=`realpath $0` -THEME=`realpath "$(dirname $0)/themes/powermenu.css"` RMENU=${RMENU:-"rmenu"} #: desc => generate options for basic operation main_options() { rmenu-build options \ - -t $THEME \ + -C $CSS \ -n ArrowRight -p ArrowLeft \ -w 550 -h 150 -M 0 } @@ -15,7 +15,7 @@ main_options() { #: desc => generate options for confirm operation confirm_options() { rmenu-build options \ - -t $THEME \ + -C $CSS \ -n ArrowRight -p ArrowLeft \ -w 300 -h 150 -M 0 } diff --git a/rmenu-plugin/src/bin/main.rs b/rmenu-plugin/src/bin/main.rs index 7aaa471..e0ad5ab 100644 --- a/rmenu-plugin/src/bin/main.rs +++ b/rmenu-plugin/src/bin/main.rs @@ -121,8 +121,8 @@ impl Into for EntryArgs { #[derive(Debug, Args)] struct OptionArgs { /// Override Applicaiton Theme - #[arg(short, long)] - pub theme: Option, + #[arg(short = 'C', long)] + pub css: Option, // search settings /// Override Default Placeholder #[arg(short = 'P', long)] @@ -176,7 +176,7 @@ struct OptionArgs { impl Into for OptionArgs { fn into(self) -> Options { Options { - theme: self.theme, + css: self.css, placeholder: self.placeholder, search_restrict: self.search_restrict, search_min_length: self.search_min_length, diff --git a/rmenu-plugin/src/lib.rs b/rmenu-plugin/src/lib.rs index a5ddde0..bb07f1b 100644 --- a/rmenu-plugin/src/lib.rs +++ b/rmenu-plugin/src/lib.rs @@ -87,7 +87,7 @@ impl Entry { pub struct Options { // base settings #[serde(skip_serializing_if = "Option::is_none")] - pub theme: Option, + pub css: Option, // search settings #[serde(skip_serializing_if = "Option::is_none")] pub placeholder: Option, diff --git a/rmenu/src/cli.rs b/rmenu/src/cli.rs index 37e6d19..6187284 100644 --- a/rmenu/src/cli.rs +++ b/rmenu/src/cli.rs @@ -54,12 +54,12 @@ pub struct Args { /// Override default configuration path #[arg(short, long)] config: Option, - /// Override base css styling + /// Override base css theme styling #[arg(long, default_value_t=String::from(DEFAULT_CSS))] - css: String, - /// Include additional css settings for themeing + theme: String, + /// Include additional css settings #[arg(long)] - theme: Option, + css: Option, // root config settings /// Override terminal command @@ -254,9 +254,9 @@ impl Args { config } - /// Load CSS or Default - pub fn get_css(&self) -> String { - let path = shellexpand::tilde(&self.css).to_string(); + /// Load CSS Theme or Default + pub fn get_theme(&self) -> String { + let path = shellexpand::tilde(&self.theme).to_string(); match read_to_string(&path) { Ok(css) => css, Err(err) => { @@ -266,10 +266,10 @@ impl Args { } } - /// Load CSS Theme or Default - pub fn get_theme(&self) -> String { - if let Some(theme) = self.theme.as_ref() { - let path = shellexpand::tilde(&theme).to_string(); + /// Load Additional CSS or Default + pub fn get_css(&self) -> String { + if let Some(css) = self.css.as_ref() { + let path = shellexpand::tilde(&css).to_string(); match read_to_string(&path) { Ok(theme) => return theme, Err(err) => log::error!("Failed to load Theme: {err:?}"), @@ -293,7 +293,7 @@ impl Args { Message::Entry(entry) => v.push(entry), Message::Options(options) => { // base settings - self.theme = self.theme.clone().or(options.theme); + self.css = self.css.clone().or(options.css); // search settings cli_replace!(c.search.placeholder, options.placeholder); cli_replace!(c.search.restrict, options.search_restrict); diff --git a/rmenu/src/gui.rs b/rmenu/src/gui.rs index ff97d83..0461f07 100644 --- a/rmenu/src/gui.rs +++ b/rmenu/src/gui.rs @@ -241,8 +241,8 @@ fn App<'a>(cx: Scope) -> Element { // complete final rendering cx.render(rsx! { style { DEFAULT_CSS_CONTENT } - style { "{cx.props.css}" } style { "{cx.props.theme}" } + style { "{cx.props.css}" } div { id: "content", class: "content", diff --git a/rmenu/src/main.rs b/rmenu/src/main.rs index 67c7ec0..c194ecf 100644 --- a/rmenu/src/main.rs +++ b/rmenu/src/main.rs @@ -20,9 +20,9 @@ static DEFAULT_CSS_CONTENT: &'static str = include_str!("../public/default.css") pub struct App { css: String, name: String, + theme: String, entries: Vec, config: config::Config, - theme: String, } //TODO: how should scripting work? @@ -66,9 +66,9 @@ fn main() -> cli::Result<()> { gui::run(App { name: "rmenu".to_owned(), css, + theme, entries, config, - theme, }); Ok(())