From 15d50528cf86e93bad19f65f1e4b47af49e94d71 Mon Sep 17 00:00:00 2001 From: Natasha Moongrave Date: Fri, 12 Jun 2026 13:37:13 +0200 Subject: Nuked everything --- .../schrottkatze/eww/configDir/scripts/bat.nu | 78 ---------------------- 1 file changed, 78 deletions(-) delete mode 100755 home/rices/schrottkatze/eww/configDir/scripts/bat.nu (limited to 'home/rices/schrottkatze/eww/configDir/scripts/bat.nu') diff --git a/home/rices/schrottkatze/eww/configDir/scripts/bat.nu b/home/rices/schrottkatze/eww/configDir/scripts/bat.nu deleted file mode 100755 index fd34c50..0000000 --- a/home/rices/schrottkatze/eww/configDir/scripts/bat.nu +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env nu - -const ICONS = [ - [ normal charging]; - [ 󰂎 󰢟 ] - [ 󰁺 󰢜 ] - [ 󰁻 󰂆 ] - [ 󰁼 󰂇 ] - [ 󰁽 󰂈 ] - [ 󰁾 󰢝 ] - [ 󰁿 󰂉 ] - [ 󰂀 󰢞 ] - [ 󰂁 󰂊 ] - [ 󰂂 󰂋 ] - [ 󰁹 󰂅 ] -]; - -const DELAY = 2sec; - -def "main auto" [] { - loop { - let paths = ls "/sys/class/power_supply" - | each {|it| $it.name | path basename} - | filter {|it| $it starts-with "BAT"}; - - if ($paths | is-not-empty) { - let result = $paths - | each {|it| get_and_format $it} - | str join " | " - | prepend "| " - | str join; - - print $result - } else { - print "" - } - sleep $DELAY; - } -} - -def main [ path: string ] { - loop { - print (get_and_format $path) - sleep $DELAY; - } -} - -def get_and_format [ path: string ] { - let fract = get_bat_charge_fraction $path; - let is_charging = get_bat_charging_status $path; - let percent = ($fract * 100) | math round; - - return $"(get_bat_icon $fract $is_charging) ($percent)%"; -} - -def get_bat_charge_fraction [ - 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 -} - -def get_bat_charging_status [ - path: string -] { - let status = open $"/sys/class/power_supply/($path)/status"; - - $status like Charging -} - -def get_bat_icon [ - frac: float - is_charging = false -] { - $ICONS | get (($frac * 10) | math round) | get (if ($is_charging) { "charging" } else { "normal" }) -} -- cgit v1.2.3