2023-10-31 08:32:40 -04:00
|
|
|
import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
import { Label, Icon, Box } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-06 17:33:47 -04:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
import Separator from '../../misc/separator.js';
|
2023-09-11 19:57:21 -04:00
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const LOW_BATT = 20;
|
2023-12-18 18:00:30 -05:00
|
|
|
const SPACING = 5;
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-09-06 17:33:47 -04:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
export default () => Box({
|
|
|
|
class_name: 'toggle-off battery',
|
2023-12-05 09:42:06 -05:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
children: [
|
|
|
|
Icon({
|
|
|
|
class_name: 'battery-indicator',
|
|
|
|
icon: Battery.bind('icon_name'),
|
|
|
|
}).hook(Battery, (self) => {
|
2023-12-17 00:01:58 -05:00
|
|
|
self.toggleClassName('charging', Battery.charging);
|
|
|
|
self.toggleClassName('charged', Battery.charged);
|
|
|
|
self.toggleClassName('low', Battery.percent < LOW_BATT);
|
2023-12-18 18:00:30 -05:00
|
|
|
}),
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
Separator(SPACING),
|
2023-12-18 18:00:30 -05:00
|
|
|
|
|
|
|
Label({
|
|
|
|
label: Battery.bind('percent')
|
|
|
|
.transform((v) => `${v}%`),
|
|
|
|
}),
|
2023-12-05 11:35:40 -05:00
|
|
|
],
|
|
|
|
});
|