Fix when acpi line has "unavailable" with 0%
This commit is contained in:
parent
c60629864d
commit
3568bebb22
1 changed files with 8 additions and 1 deletions
|
@ -127,7 +127,14 @@ impl BattInfo {
|
||||||
cmd_builder.arg("-b");
|
cmd_builder.arg("-b");
|
||||||
let output = cmd_builder.output()?;
|
let output = cmd_builder.output()?;
|
||||||
let string = String::from_utf8(output.stdout)?;
|
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() {
|
if regex_captures_result.is_none() {
|
||||||
self.acpi_error = true;
|
self.acpi_error = true;
|
||||||
return Err(Error::Generic("battinfo: regex captured nothing".into()));
|
return Err(Error::Generic("battinfo: regex captured nothing".into()));
|
||||||
|
|
Loading…
Reference in a new issue