pikabar/pika-hyprland-settings/etc/skel/.config/ags/widgets/batt.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-11-17 15:45:46 +01:00
const { Widget } = ags;
const { Battery } = ags.Service;
import { getBattery } from '../lib.js';
export const Batt = () => Widget.Box({
halign: 'end',
tooltipText: 'Battery Remaining',
valign: 'center',
className: '',
connections: [[Battery, box => {
box.visible = Battery?.available;
}]],
children: [
Widget.Label({
halign: 'end',
valign: 'center',
className: 'txt-larger txt icon-material',
style: 'margin-right: 0.5rem; margin-top: 1px;',
label: 'battery_5_bar',
connections: [[Battery, label => {
if (Battery?.available) {
label.label = getBattery(Battery);
}
}]],
}),
Widget.Label({
halign: 'end',
valign: 'center',
className: 'txt-norm txt',
connections: [[Battery, label => {
if (Battery?.available) {
label.label = Battery?.percent + "%";
}
}]],
}),
],
});