fix: hide the charge limit toggle on unsupported devices
This commit is contained in:
parent
98e1cdec52
commit
65b8376a40
4 changed files with 67 additions and 47 deletions
|
|
@ -214,24 +214,22 @@ pub enum PowerProfileUpdate {
|
|||
}
|
||||
|
||||
// check if battery charging thresholds is set
|
||||
pub async fn get_charging_limit() -> bool {
|
||||
pub async fn get_charging_limit() -> anyhow::Result<bool> {
|
||||
if let Ok(conn) = Connection::system().await {
|
||||
if let Ok(backend) = get_power_backend(&conn, &BackendType::S76PowerDaemon).await {
|
||||
match backend {
|
||||
Backend::S76PowerDaemon(proxy) => {
|
||||
if let Ok((start, end)) = proxy.get_charge_thresholds().await {
|
||||
return start > 0 || end > 0;
|
||||
return Ok(start > 0 || end > 0);
|
||||
}
|
||||
}
|
||||
Backend::PowerProfilesDaemon(_) => {
|
||||
tracing::info!("Power Profiles Daemon is not supported.");
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
false
|
||||
anyhow::bail!("Unsupported")
|
||||
}
|
||||
|
||||
// set battery charging thresholds via s76 power_daemon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue