diff --git a/Cargo.lock b/Cargo.lock index b8da566cfb..eb6848c071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "i3status-rs" -version = "0.14.5" +version = "0.14.7" dependencies = [ "assert_fs", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 77dde9e5ce..3ece1dae8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ description = "A feature-rich and resource-friendly replacement for i3status, wr repository = "https://github.com/greshake/i3status-rust/" readme = "README.md" license = "GPLv3" -version = "0.14.5" +version = "0.14.7" authors = ["Kai Greshake ", "Contributors on GitHub (https://github.com/greshake/i3status-rust/graphs/contributors)"] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 83829d918b..5a4f159861 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,7 +110,7 @@ fn main() { ::std::process::exit(1); } - let error_widget = TextWidget::new(Default::default(), 9999999999) + let error_widget = TextWidget::new(Default::default(), 0) .with_state(State::Critical) .with_text(&format!("{:?}", error)); let error_rendered = error_widget.get_rendered(); diff --git a/src/themes.rs b/src/themes.rs index 02eb0d4e24..bb25a69081 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -247,6 +247,49 @@ impl Default for Theme { } } +#[derive(Deserialize, Debug, Clone)] +pub struct ThemeFromFile { + pub native_separators: Option, + pub idle_bg: Option, + pub idle_fg: Option, + pub info_bg: Option, + pub info_fg: Option, + pub good_bg: Option, + pub good_fg: Option, + pub warning_bg: Option, + pub warning_fg: Option, + pub critical_bg: Option, + pub critical_fg: Option, + pub separator: String, + pub separator_bg: Option, + pub separator_fg: Option, + pub alternating_tint_bg: Option, + pub alternating_tint_fg: Option, +} + +impl Into for ThemeFromFile { + fn into(self) -> Theme { + Theme { + native_separators: self.native_separators, + idle_bg: self.idle_bg, + idle_fg: self.idle_fg, + info_bg: self.info_bg, + info_fg: self.info_fg, + good_bg: self.good_bg, + good_fg: self.good_fg, + warning_bg: self.warning_bg, + warning_fg: self.warning_fg, + critical_bg: self.critical_bg, + critical_fg: self.critical_fg, + separator: self.separator, + separator_bg: self.separator_bg, + separator_fg: self.separator_fg, + alternating_tint_bg: self.alternating_tint_bg, + alternating_tint_fg: self.alternating_tint_fg, + } + } +} + impl Theme { pub fn from_name(name: &str) -> Option { match name { @@ -272,7 +315,7 @@ impl Theme { .join(file); let share_path = Path::new(util::USR_SHARE_PATH).join("themes").join(file); - if full_path.exists() { + let theme: Option = if full_path.exists() { util::deserialize_file(&full_path).ok() } else if xdg_path.exists() { util::deserialize_file(&xdg_path).ok() @@ -280,7 +323,9 @@ impl Theme { util::deserialize_file(&share_path).ok() } else { None - } + }; + + theme.map(|theme| theme.into()) } }