1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

power_supply: rename is_battery to get_type and don't compare the type

This commit is contained in:
RGBCube 2025-05-19 18:08:52 +03:00
parent 2704379b42
commit 2995909544
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -137,19 +137,20 @@ impl PowerSupply {
Ok(power_supplies) Ok(power_supplies)
} }
fn is_battery(&self) -> anyhow::Result<bool> { fn get_type(&self) -> anyhow::Result<String> {
let type_path = self.path.join("type"); let type_path = self.path.join("type");
let type_ = fs::read_to_string(&type_path) let type_ = fs::read_to_string(&type_path)
.with_context(|| format!("failed to read '{path}'", path = type_path.display()))?; .with_context(|| format!("failed to read '{path}'", path = type_path.display()))?;
Ok(type_ == "Battery") Ok(type_)
} }
pub fn rescan(&mut self) -> anyhow::Result<()> { pub fn rescan(&mut self) -> anyhow::Result<()> {
let threshold_config = self let threshold_config = self
.is_battery() .get_type()
.with_context(|| format!("failed to determine what type of power supply '{self}' is"))? .with_context(|| format!("failed to determine what type of power supply '{self}' is"))?
.eq("Battery")
.then(|| { .then(|| {
for config in POWER_SUPPLY_THRESHOLD_CONFIGS { for config in POWER_SUPPLY_THRESHOLD_CONFIGS {
if self.path.join(config.path_start).exists() if self.path.join(config.path_start).exists()