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 rustc_hash::FxHashMap;
|
||||||
use std::{path::PathBuf, sync::LazyLock, time::Duration};
|
use std::{path::PathBuf, time::Duration};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
// XXX improve
|
// XXX improve
|
||||||
|
|
@ -169,6 +169,20 @@ impl CosmicBatteryApplet {
|
||||||
self.charging_limit = Some(limit);
|
self.charging_limit = Some(limit);
|
||||||
self.update_battery(self.battery_percent, self.on_battery);
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -521,19 +535,9 @@ impl cosmic::Application for CosmicBatteryApplet {
|
||||||
let applet_padding = self.core.applet.suggested_padding(true);
|
let applet_padding = self.core.applet.suggested_padding(true);
|
||||||
|
|
||||||
let mut children = vec![
|
let mut children = vec![
|
||||||
icon::from_name(if self.no_battery {
|
icon::from_name(self.panel_icon_name())
|
||||||
if self.screen_brightness.is_some() {
|
.size(suggested_size.0)
|
||||||
self.display_icon_name.as_str()
|
.into(),
|
||||||
} else if self.kbd_brightness.is_some() {
|
|
||||||
"keyboard-brightness-symbolic"
|
|
||||||
} else {
|
|
||||||
self.icon_name.as_str()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.icon_name.as_str()
|
|
||||||
})
|
|
||||||
.size(suggested_size.0)
|
|
||||||
.into(),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if self.config.show_percentage && !self.no_battery {
|
if self.config.show_percentage && !self.no_battery {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue