fix(agsV2): use agsV1 logic for battery icons
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
b40d7b80b9
commit
11223860f7
2 changed files with 30 additions and 10 deletions
|
@ -12,16 +12,28 @@ const SPACING = 5;
|
||||||
export default () => (
|
export default () => (
|
||||||
<box className="bar-item battery">
|
<box className="bar-item battery">
|
||||||
<icon
|
<icon
|
||||||
icon={bind(Battery, 'batteryIconName')}
|
|
||||||
|
|
||||||
setup={(self: Widget.Icon) => {
|
setup={(self: Widget.Icon) => {
|
||||||
Battery.connect('notify::percentage', () => {
|
const update = () => {
|
||||||
const percent = Math.round(Battery.get_percentage() * 100);
|
const percent = Math.round(Battery.get_percentage() * 100);
|
||||||
|
const level = Math.floor(percent / 10) * 10;
|
||||||
|
const isCharging = Battery.get_charging();
|
||||||
|
const charged = percent === 100 && isCharging;
|
||||||
|
const iconName = charged ?
|
||||||
|
'battery-level-100-charged-symbolic' :
|
||||||
|
`battery-level-${level}${isCharging ?
|
||||||
|
'-charging' :
|
||||||
|
''}-symbolic`;
|
||||||
|
|
||||||
self.toggleClassName('charging', Battery.get_charging());
|
self.set_icon(iconName);
|
||||||
self.toggleClassName('charged', percent === 100);
|
|
||||||
|
self.toggleClassName('charging', isCharging);
|
||||||
|
self.toggleClassName('charged', charged);
|
||||||
self.toggleClassName('low', percent < LOW_BATT);
|
self.toggleClassName('low', percent < LOW_BATT);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
Battery.connect('notify::percentage', () => update());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Astal } from 'astal';
|
import { Astal, Gtk } from 'astal';
|
||||||
|
|
||||||
import Battery from './items/battery';
|
import Battery from './items/battery';
|
||||||
|
|
||||||
|
@ -15,9 +15,17 @@ export default () => {
|
||||||
Astal.WindowAnchor.RIGHT
|
Astal.WindowAnchor.RIGHT
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<box className="bar widget">
|
<centerbox className="bar widget">
|
||||||
<Battery />
|
<box hexpand halign={Gtk.Align.START}>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
|
<box>
|
||||||
|
</box>
|
||||||
|
|
||||||
|
<box hexpand halign={Gtk.Align.END}>
|
||||||
|
<Battery />
|
||||||
|
</box>
|
||||||
|
</centerbox>
|
||||||
</BarRevealer>
|
</BarRevealer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue