Closed svartalf closed 4 years ago
@pizzafox, I dropped a quick fix, would you be able to test it with the starship
of yours?
You can do that by adding the following lines at the end of the Cargo.toml
file and rebuilding the starship
project:
[patch.crates-io]
battery = { git = "https://github.com/svartalf/rust-battery.git", branch = "issue-40" }
Or with the patch:
diff --git a/Cargo.toml b/Cargo.toml
index 2b5ee64..60c16ca 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -57,3 +57,6 @@ lto = true
[[bin]]
name = "starship"
path = "src/main.rs"
+
+[patch.crates-io]
+battery = { git = "https://github.com/svartalf/rust-battery.git", branch = "issue-40" }
This fixes the issue! The battery is displaying properly in Starship.
I just upgraded to WSL 2 which has a much better integration to the system APIs... Including battery!
This bug is no longer occurring on for me despite not upgrading rust-battery to a patched version.
@pizzafox thanks for an update, good to know!
According to https://github.com/starship/starship/issues/613#issuecomment-548873632, there exist a possibility when both
energy_full_design
andcharge_full_design
files are missing for the battery device, so fetching fails with an error here: https://github.com/svartalf/rust-battery/blob/08b2ad579d135dbe48d52ff31a35df307c173eb6/battery/src/platform/linux/sysfs/source.rs#L183upower
just falls back to0.0
value, but that might affectstate_of_health
https://github.com/svartalf/rust-battery/blob/08b2ad579d135dbe48d52ff31a35df307c173eb6/battery/src/platform/linux/sysfs/source.rs#L137
and
energy
parameters:https://github.com/svartalf/rust-battery/blob/08b2ad579d135dbe48d52ff31a35df307c173eb6/battery/src/platform/linux/sysfs/source.rs#L168