Commit bd18313d authored by Florian Müllner's avatar Florian Müllner

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] adwaita-icon-theme#6

!561
parent 2ff7a78b
Pipeline #94926 passed with stages
in 3 minutes and 15 seconds
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment