nixos-configs/devices/wim/config/ags/ts/bar/items/battery.ts
matt1432 7c0e1658da
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags wim): bundle all files through imports
2024-01-13 23:38:31 -05:00

31 lines
835 B
TypeScript

import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
import { Label, Icon, Box } from 'resource:///com/github/Aylur/ags/widget.js';
import Separator from '../../misc/separator.ts';
const LOW_BATT = 20;
const SPACING = 5;
export default () => Box({
class_name: 'toggle-off battery',
children: [
Icon({
class_name: 'battery-indicator',
icon: Battery.bind('icon_name'),
}).hook(Battery, (self) => {
self.toggleClassName('charging', Battery.charging);
self.toggleClassName('charged', Battery.charged);
self.toggleClassName('low', Battery.percent < LOW_BATT);
}),
Separator(SPACING),
Label({
label: Battery.bind('percent')
.transform((v) => `${v}%`),
}),
],
});