From d32f8a170e8037ad4f7d37e6cf659193876a06fd Mon Sep 17 00:00:00 2001 From: Max Verevkin Date: Sun, 14 Feb 2021 14:05:03 +0200 Subject: [PATCH 1/4] fix loading theme form file --- src/themes.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) 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()) } } From 4b206ffe6c00c646730e29a1f4260055b67b9074 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Sun, 14 Feb 2021 22:28:43 +0900 Subject: [PATCH 2/4] bump ver for bugfix --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8da566cfb..b4d9ec2338 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "i3status-rs" -version = "0.14.5" +version = "0.14.6" dependencies = [ "assert_fs", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 77dde9e5ce..8bd61aab15 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.6" authors = ["Kai Greshake ", "Contributors on GitHub (https://github.com/greshake/i3status-rust/graphs/contributors)"] edition = "2018" From a765f6cee38262c47012d7cdf9ba5e0ad1faaee9 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Mon, 15 Feb 2021 18:19:57 +0900 Subject: [PATCH 3/4] Backport id fix --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 03d4fdfcc043e0c61b268bc295fe554f42d602b3 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Mon, 15 Feb 2021 18:35:18 +0900 Subject: [PATCH 4/4] bump ver for bugfix --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4d9ec2338..eb6848c071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "i3status-rs" -version = "0.14.6" +version = "0.14.7" dependencies = [ "assert_fs", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 8bd61aab15..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.6" +version = "0.14.7" authors = ["Kai Greshake ", "Contributors on GitHub (https://github.com/greshake/i3status-rust/graphs/contributors)"] edition = "2018"