import Battery from "gi://AstalBattery" import PowerProfiles from "gi://AstalPowerProfiles" import Hyprland from "gi://AstalHyprland" import { popup } from "./popup" import { Astal, Gtk, Widget } from "astal/gtk3" import { mergeBindings } from "/usr/share/astal/gjs/_astal" import { bind } from "astal" const hyprland = Hyprland.get_default() const batt = Battery.get_default() const powerProfiles = PowerProfiles.get_default() const percentage = bind(batt, "percentage").as((p) => `${Math.round(p*100)}%`) const charging = bind(batt, "charging") const toFull = bind(batt, "timeToFull").as((t) => t.toString()) const toEmpty = bind(batt, "timeToEmpty").as((t) => t.toString()) function profileButton(label: string, profile: string) { return } function BattWindow() { const { TOP, LEFT } = Astal.WindowAnchor return `${e}Wh`), })}> c)} /> `${w}W`), }), new Widget.Label({ className: "smallText", label: bind(batt, "charging").as( (c) => c ? "Charging" : "Discharging" ), }), ] })}> { let s = (b[0] ? b[1] : b[2]) return `${Math.floor(s/3600)}H ${Math.floor((s%3600)/60)}M` } ), }), new Widget.Label({ className: "title", label: charging.as(c => c ? "To full" : "To empty"), }), ] })}> {profileButton("Power Saver", "power-saver")} {profileButton("Balanced", "balanced")} {profileButton("Performance", "performance")} } export default function battery() { return }