diff --git a/nixosModules/ags/v2/widgets/bar/items/battery.tsx b/nixosModules/ags/v2/widgets/bar/items/battery.tsx index 880a5633..18d1040c 100644 --- a/nixosModules/ags/v2/widgets/bar/items/battery.tsx +++ b/nixosModules/ags/v2/widgets/bar/items/battery.tsx @@ -12,16 +12,28 @@ const SPACING = 5; export default () => ( { - Battery.connect('notify::percentage', () => { + const update = () => { 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.toggleClassName('charged', percent === 100); + self.set_icon(iconName); + + self.toggleClassName('charging', isCharging); + self.toggleClassName('charged', charged); self.toggleClassName('low', percent < LOW_BATT); - }); + }; + + update(); + + Battery.connect('notify::percentage', () => update()); }} /> diff --git a/nixosModules/ags/v2/widgets/bar/wim.tsx b/nixosModules/ags/v2/widgets/bar/wim.tsx index f090c785..558b9948 100644 --- a/nixosModules/ags/v2/widgets/bar/wim.tsx +++ b/nixosModules/ags/v2/widgets/bar/wim.tsx @@ -1,4 +1,4 @@ -import { Astal } from 'astal'; +import { Astal, Gtk } from 'astal'; import Battery from './items/battery'; @@ -15,9 +15,17 @@ export default () => { Astal.WindowAnchor.RIGHT } > - - - + + + + + + + + + + + ); };