From 0ae98568e89c7792b0433e5bb450c6706562eb71 Mon Sep 17 00:00:00 2001 From: foswret Date: Wed, 2 Jul 2025 11:16:43 -0500 Subject: first commit --- scripts/battery.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/battery.sh (limited to 'scripts') diff --git a/scripts/battery.sh b/scripts/battery.sh new file mode 100755 index 0000000..3872f11 --- /dev/null +++ b/scripts/battery.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Made for use in dwmblocks + +num_of_batteries=0 +sum_battery_totals=0 +icon_array=('󱃍' '󰁺' '󰁻' '󰁼' '󰁽' '󰁾' '󰁿' '󰂀' '󰂁' '󰂂' '󰁹') + +for BATT in /sys/class/power_supply/BAT*/capacity; do + sum_battery_totals=$((sum_battery_totals + $(cat $BATT))) + num_of_batteries=$((num_of_batteries + 1)) +done + +final_percentage=$((sum_battery_totals / num_of_batteries)) +ac_state=$(cat /sys/class/power_supply/AC/online) + +if [ $ac_state -eq 1 ] +then + echo -n " 󱐋 " +fi +echo -n "${icon_array[$((final_percentage / 10))]} " + +printf "%d%% \n" $final_percentage -- cgit v1.2.3