added battery health and cycles count

This commit is contained in:
wt committed 2025-03-18 22:26:46 +07:00
1 parent 8118227936
commit cf7bf010f9
2 files changed
+45 -10

No files matched your search

+8 -10
View File
@@ -1,17 +1,15 @@
import { Astal, App, Gtk } from "astal/gtk3";
import Battery from "gi://AstalBattery";
import { bind } from "astal";
import { bind, Variable } from "astal";
import {cycles_count, health} from "./helpers.ts";
const BatteryMenu = () => {
const { TOP, RIGHT } = Astal.WindowAnchor;
const { START, END } = Gtk.Align;
const { START, END, CENTER } = Gtk.Align;
const bat = Battery.get_default();
console.log(
bat.charging,
bat.capacity,
bat.energyFull,
bat.energy_full_design,
);
const batcycles = Variable<string>("").poll(5000, () => cycles_count());
const bathealth = Variable<string>("").poll(5000, () => health());
return (
<window
anchor={TOP | RIGHT}
@@ -55,7 +53,7 @@ const BatteryMenu = () => {
halign={START}
label="Health:"
/>
<label hexpand halign={END} label="92.5 %" />
<label hexpand halign={END} label={bathealth()} />
</box>
<box>
<label
@@ -64,7 +62,7 @@ const BatteryMenu = () => {
halign={START}
label="Charge cycles:"
/>
<label hexpand halign={END} label="325" />
<label hexpand halign={END} label={batcycles()} />
</box>
<box>
<label