This commit is contained in:
agryphus 2024-03-18 17:14:15 -04:00
parent 3648827637
commit c8d7b4c090
8 changed files with 415 additions and 0 deletions

View file

@ -0,0 +1,24 @@
const { exec, execAsync } = Utils;
export const Battery = () => Widget.Button({
class_name: "battery",
child: Widget.Label({
setup: (self) => {self.poll(1000, (self) =>
execAsync("block_battery")
.then((out) => {
self.label = out;
let num = Number(out.substring(2, out.length - 1));
// Turn red at low battery
if (num < 20) {
self.class_name = "module, critical";
} else {
self.class_name = "module";
};
})
.catch(console.error),
)},
}),
on_clicked: () => {},
});