import { Binding } from "astal"; type Substitution = { charging?: string, idle?: string } export const getBatteryIcon = (percentage: number, charging: Binding) => { const levels = Array.from({ length: 10 }, (_, i) => (i + 1) * 10); const level = levels.find((level) => percentage <= level)!; const substitutions: Record = { 100: { charging: "battery-level-100-charged-symbolic" } }; return charging.as(c => c ? substitutions[level]?.charging || `battery-level-${level}-charging-symbolic` : substitutions[level]?.idle || `battery-level-${level}-symbolic` ); };