nix-configs/modules/desktop-environment/home/panels/eww/scripts/bat.nu
2024-08-26 13:41:37 +02:00

23 lines
463 B
Text

#!/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
}