2023-10-31 08:32:40 -04:00
|
|
|
import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
|
2023-11-13 16:19:09 -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-09-06 17:33:47 -04:00
|
|
|
|
2023-11-13 16:19:09 -05:00
|
|
|
const Indicator = () => Icon({
|
2023-10-20 23:11:21 -04:00
|
|
|
className: 'battery-indicator',
|
2023-11-13 16:19:09 -05:00
|
|
|
binds: [['icon', Battery, 'icon-name']],
|
|
|
|
connections: [[Battery, self => {
|
|
|
|
self.toggleClassName('charging', Battery.charging);
|
|
|
|
self.toggleClassName('charged', Battery.charged);
|
|
|
|
self.toggleClassName('low', Battery.percent < 20);
|
2023-10-20 23:11:21 -04:00
|
|
|
}]],
|
2023-09-06 17:33:47 -04:00
|
|
|
});
|
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
const LevelLabel = props => Label({
|
2023-10-20 23:11:21 -04:00
|
|
|
...props,
|
|
|
|
className: 'label',
|
|
|
|
connections: [[Battery, self => self.label = `${Battery.percent}%`]],
|
2023-09-06 17:33:47 -04:00
|
|
|
});
|
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
export default () => Box({
|
2023-10-20 23:11:21 -04:00
|
|
|
className: 'toggle-off battery',
|
|
|
|
children: [
|
|
|
|
Indicator(),
|
|
|
|
Separator(5),
|
|
|
|
LevelLabel(),
|
|
|
|
],
|
2023-09-06 17:33:47 -04:00
|
|
|
});
|