Compare commits

...

2 commits

Author SHA1 Message Date
Stephen Seo e8ff22d88c Version 0.1.13 2023-06-05 15:48:10 +09:00
Stephen Seo 3568bebb22 Fix when acpi line has "unavailable" with 0% 2023-06-05 15:45:25 +09:00
4 changed files with 15 additions and 3 deletions

2
Cargo.lock generated
View file

@ -141,7 +141,7 @@ dependencies = [
[[package]]
name = "swaybar_info"
version = "0.1.12"
version = "0.1.13"
dependencies = [
"chrono",
"regex",

View file

@ -1,6 +1,6 @@
[package]
name = "swaybar_info"
version = "0.1.12"
version = "0.1.13"
edition = "2021"
description = "Provides swaybar with info to be displayed"
license = "MIT"

View file

@ -2,6 +2,11 @@
## Upcoming Changes
## 0.1.13
Fix to workaround when `acpi` output contains a `0%` line with "unavailable".
When such a line is encountered, it is ignored.
## 0.1.12
Some refactoring of the code related to colorizing the netgraph.

View file

@ -127,7 +127,14 @@ impl BattInfo {
cmd_builder.arg("-b");
let output = cmd_builder.output()?;
let string = String::from_utf8(output.stdout)?;
let regex_captures_result = self.regex.captures(&string);
let mut last_line = "unknown".to_owned();
for line in string.lines() {
if !line.contains("unavailable") {
last_line = line.to_owned();
break;
}
}
let regex_captures_result = self.regex.captures(&last_line);
if regex_captures_result.is_none() {
self.acpi_error = true;
return Err(Error::Generic("battinfo: regex captured nothing".into()));