Skip to content

Commit a7be043

Browse files
l-constmmstick
authored andcommitted
fix(power): Fix battery charged icon when a device is fully charged.
1 parent 9c274a7 commit a7be043

File tree

1 file changed

+10
-1
lines changed
  • cosmic-settings/src/pages/power/backend

1 file changed

+10
-1
lines changed

cosmic-settings/src/pages/power/backend/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ impl Battery {
308308

309309
let is_charging = matches!(battery_state, BatteryState::Charging);
310310

311+
let charged = matches!(battery_state, BatteryState::FullyCharged)
312+
|| matches!(battery_state, BatteryState::Charging)
313+
&& (percent - 100.0_f64).abs() < f64::EPSILON;
314+
311315
if !is_charging {
312316
if let Ok(time) = proxy.time_to_empty().await {
313317
if let Ok(dur) = Duration::from_std(std::time::Duration::from_secs(time as u64)) {
@@ -339,7 +343,12 @@ impl Battery {
339343
} else {
340344
0
341345
};
342-
let charging = if is_charging { "charging-" } else { "" };
346+
// Due to not having a specific icon for charged we use the charging one
347+
let charging = if is_charging || charged {
348+
"charging-"
349+
} else {
350+
""
351+
};
343352

344353
let icon_name =
345354
format!("cosmic-applet-battery-level-{battery_percent}-{charging}symbolic",);

0 commit comments

Comments
 (0)