- Scaling 16px base pour ultrawide 3440x1440 - Bar: CPU/RAM/GPU visible, media single player (skip playerctld), network tooltip LAN/WAN IPv4 - Volume: class module pour sizing cohérent - Battery: désactivé (PC fixe) - Clock: tooltip calendrier + uptime - BrainPower: panel enrichi (focus, session, intentions, todos, repos git, derniers commits) - App: BrainPower sur moniteur principal uniquement - Heartbeat: Layer.TOP pour compatibilité COSMIC
31 lines
897 B
TypeScript
31 lines
897 B
TypeScript
import AstalBattery from "gi://AstalBattery"
|
|
import { createBinding } from "ags"
|
|
|
|
export default function Battery() {
|
|
const bat = AstalBattery.get_default()
|
|
|
|
const text = createBinding(bat, "percentage")((p: number) => {
|
|
const pct = Math.round(p * 100)
|
|
const isCharging = bat.charging
|
|
let icon = ""
|
|
if (isCharging) icon = ""
|
|
else if (pct > 90) icon = ""
|
|
else if (pct > 70) icon = ""
|
|
else if (pct > 50) icon = ""
|
|
else if (pct > 30) icon = ""
|
|
else if (pct > 10) icon = ""
|
|
else icon = ""
|
|
return `${icon} ${pct}%`
|
|
})
|
|
|
|
const cls = createBinding(bat, "percentage")((p: number) => {
|
|
const pct = Math.round(p * 100)
|
|
if (bat.charging) return "battery charging"
|
|
if (pct <= 10) return "battery low"
|
|
if (pct <= 20) return "battery warning"
|
|
return "battery"
|
|
})
|
|
|
|
return <label class={cls} label={text} />
|
|
}
|