From 2995909544627981a3f9a93d354faa7fd83c70ab Mon Sep 17 00:00:00 2001 From: RGBCube Date: Mon, 19 May 2025 18:08:52 +0300 Subject: [PATCH] power_supply: rename is_battery to get_type and don't compare the type --- src/power_supply.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/power_supply.rs b/src/power_supply.rs index 06d3ec8..9ec00ab 100644 --- a/src/power_supply.rs +++ b/src/power_supply.rs @@ -137,19 +137,20 @@ impl PowerSupply { Ok(power_supplies) } - fn is_battery(&self) -> anyhow::Result { + fn get_type(&self) -> anyhow::Result { let type_path = self.path.join("type"); let type_ = fs::read_to_string(&type_path) .with_context(|| format!("failed to read '{path}'", path = type_path.display()))?; - Ok(type_ == "Battery") + Ok(type_) } pub fn rescan(&mut self) -> anyhow::Result<()> { let threshold_config = self - .is_battery() + .get_type() .with_context(|| format!("failed to determine what type of power supply '{self}' is"))? + .eq("Battery") .then(|| { for config in POWER_SUPPLY_THRESHOLD_CONFIGS { if self.path.join(config.path_start).exists()