nix-configs/modules/desktop-environment/home/panels/eww/scripts/bat.nu

24 lines
463 B
Text
Raw Normal View History

2024-08-26 13:41:37 +02:00
#!/usr/bin/env nu
const ICONS = [
[ 󰂎 󰢟 ]
[ 󰁺 󰢜 ]
[ 󰁻 󰂆 ]
[ 󰁼 󰂇 ]
[ 󰁽 󰂈 ]
[ 󰁾 󰢝 ]
[ 󰁿 󰂉 ]
[ 󰂀 󰢞 ]
[ 󰂁 󰂊 ]
[ 󰂂 󰂋 ]
[ 󰁹 󰂅 ]
];
def get_bat_percent [path: string] {
let energy_full = open $"/sys/class/power_supply/($path)/energy_full" | into float;
let energy_now = open $"/sys/class/power_supply/($path)/energy_now" | into float;
($energy_now / $energy_full) * 100
}