From cf7bf010f9b940c4cfe15162894142abc7404abe Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Tue, 18 Mar 2025 22:26:46 +0700 Subject: [PATCH] added battery health and cycles count --- widget/menus/BatteryMenu/BatteryMenu.tsx | 18 +++++------- widget/menus/BatteryMenu/helpers.ts | 37 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 widget/menus/BatteryMenu/helpers.ts diff --git a/widget/menus/BatteryMenu/BatteryMenu.tsx b/widget/menus/BatteryMenu/BatteryMenu.tsx index d71f41c..f7cd282 100644 --- a/widget/menus/BatteryMenu/BatteryMenu.tsx +++ b/widget/menus/BatteryMenu/BatteryMenu.tsx @@ -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("").poll(5000, () => cycles_count()); + const bathealth = Variable("").poll(5000, () => health()); + return ( { halign={START} label="Health:" /> -