updated battery module

This commit is contained in:
wt committed 2025-03-12 23:38:25 +07:00
1 parent f1c32ead5d
commit 1423da4034
4 files changed
+10 -1

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
.Battery {
icon {
margin: 0 5px;
}
label {
margin: 0 5px 0 0;
}
}
+15
View File
@@ -0,0 +1,15 @@
import { bind } from "astal"
import Battery from "gi://AstalBattery"
export default function BatteryLevel() {
const bat = Battery.get_default()
console.log(bat.charging, bat.capacity, bat.energyFull, bat.energy_full_design)
return <box className="Battery"
visible={bind(bat, "isPresent")}>
<icon icon={bind(bat, "batteryIconName")} />
<label label={bind(bat, "percentage").as(p =>
`${Math.floor(p * 100)} %`
)} />
</box>
}