Flake for my NixOS devices
at main 46 lines 804 B view raw
1#!/usr/bin/env nu 2 3let icons = { 4 "charging": [ 5 "󰢜", 6 "󰂆", 7 "󰂇", 8 "󰂈", 9 "󰢝", 10 "󰂉", 11 "󰢞", 12 "󰂊", 13 "󰂋", 14 "󰂅" 15 ], 16 "default": [ 17 "󰁺", 18 "󰁻", 19 "󰁼", 20 "󰁽", 21 "󰁾", 22 "󰁿", 23 "󰂀", 24 "󰂁", 25 "󰂂", 26 "󰁹" 27 ] 28} 29 30let percent = open /sys/class/power_supply/BAT1/capacity | into int 31 32let status = open /sys/class/power_supply/BAT1/status | str trim 33 34let idx = if $percent == 100 { 35 9 36} else { 37 ($percent / 10) | into int 38} 39 40let icon = if $status == "Charging" or $status == "Full" { 41 ($icons | get "charging" | get $idx) + " " 42} else { 43 $icons | get "default" | get $idx 44} 45 46echo $" | ($icon) ($percent)%"