fix(battery): show plug icon without battery (#1432)
This commit is contained in:
parent
1f7c59fb2b
commit
0441c67b10
1 changed files with 18 additions and 14 deletions
|
|
@ -40,7 +40,7 @@ use cosmic_settings_upower_subscription::{
|
|||
};
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::{path::PathBuf, sync::LazyLock, time::Duration};
|
||||
use std::{path::PathBuf, time::Duration};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
// XXX improve
|
||||
|
|
@ -169,6 +169,20 @@ impl CosmicBatteryApplet {
|
|||
self.charging_limit = Some(limit);
|
||||
self.update_battery(self.battery_percent, self.on_battery);
|
||||
}
|
||||
|
||||
fn panel_icon_name(&self) -> &str {
|
||||
if self.no_battery {
|
||||
if self.screen_brightness.is_some() {
|
||||
self.display_icon_name.as_str()
|
||||
} else if self.kbd_brightness.is_some() {
|
||||
"keyboard-brightness-symbolic"
|
||||
} else {
|
||||
"plugged-into-power-symbolic"
|
||||
}
|
||||
} else {
|
||||
self.icon_name.as_str()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -521,17 +535,7 @@ impl cosmic::Application for CosmicBatteryApplet {
|
|||
let applet_padding = self.core.applet.suggested_padding(true);
|
||||
|
||||
let mut children = vec![
|
||||
icon::from_name(if self.no_battery {
|
||||
if self.screen_brightness.is_some() {
|
||||
self.display_icon_name.as_str()
|
||||
} else if self.kbd_brightness.is_some() {
|
||||
"keyboard-brightness-symbolic"
|
||||
} else {
|
||||
self.icon_name.as_str()
|
||||
}
|
||||
} else {
|
||||
self.icon_name.as_str()
|
||||
})
|
||||
icon::from_name(self.panel_icon_name())
|
||||
.size(suggested_size.0)
|
||||
.into(),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue