[gnome-shell] power: Use more fine-grained battery levels
- From: Florian MĂźllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] power: Use more fine-grained battery levels
- Date: Fri, 12 Jul 2019 23:25:52 +0000 (UTC)
commit bd18313d125aa1873c21b9cce9bbf81a335e48b0
Author: Florian MĂźllner <fmuellner gnome org>
Date: Tue May 28 17:56:36 2019 +0000
power: Use more fine-grained battery levels
Adwaita-icon-theme added new battery icons which represent battery levels
in 10% steps[0]. Use these if they are available, otherwise fall back to
the existing icon names for compatibility with older icon themes.
[0] https://gitlab.gnome.org/GNOME/adwaita-icon-theme/issues/6
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/561
js/ui/status/power.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index cd1c01d86..8ffb0c631 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -107,10 +107,20 @@ var Indicator = class extends PanelMenu.SystemIndicator {
}
// The icons
- let icon = this._proxy.IconName;
+ let chargingState = this._proxy.State == UPower.DeviceState.CHARGING
+ ? '-charging' : '';
+ let fillLevel = 10 * Math.floor(this._proxy.Percentage / 10);
+ let icon = this._proxy.State == UPower.DeviceState.FULLY_CHARGED
+ ? 'battery-level-100-charged-symbolic'
+ : `battery-level-${fillLevel}${chargingState}-symbolic`;
+
this._indicator.icon_name = icon;
this._item.icon.icon_name = icon;
+ let fallbackIcon = this._proxy.IconName;
+ this._indicator.fallback_icon_name = fallbackIcon;
+ this._item.icon.fallback_icon_name = fallbackIcon;
+
// The icon label
let label;
if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]