fix(power): Fix battery charged icon when a device is fully charged.
This commit is contained in:
parent
9c274a759b
commit
a7be043ebe
1 changed files with 10 additions and 1 deletions
|
|
@ -308,6 +308,10 @@ impl Battery {
|
||||||
|
|
||||||
let is_charging = matches!(battery_state, BatteryState::Charging);
|
let is_charging = matches!(battery_state, BatteryState::Charging);
|
||||||
|
|
||||||
|
let charged = matches!(battery_state, BatteryState::FullyCharged)
|
||||||
|
|| matches!(battery_state, BatteryState::Charging)
|
||||||
|
&& (percent - 100.0_f64).abs() < f64::EPSILON;
|
||||||
|
|
||||||
if !is_charging {
|
if !is_charging {
|
||||||
if let Ok(time) = proxy.time_to_empty().await {
|
if let Ok(time) = proxy.time_to_empty().await {
|
||||||
if let Ok(dur) = Duration::from_std(std::time::Duration::from_secs(time as u64)) {
|
if let Ok(dur) = Duration::from_std(std::time::Duration::from_secs(time as u64)) {
|
||||||
|
|
@ -339,7 +343,12 @@ impl Battery {
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
let charging = if is_charging { "charging-" } else { "" };
|
// Due to not having a specific icon for charged we use the charging one
|
||||||
|
let charging = if is_charging || charged {
|
||||||
|
"charging-"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
let icon_name =
|
let icon_name =
|
||||||
format!("cosmic-applet-battery-level-{battery_percent}-{charging}symbolic",);
|
format!("cosmic-applet-battery-level-{battery_percent}-{charging}symbolic",);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue