#!/bin/sh # Display the current battery status. notify() { dunstify \ -i battery-good-symbolic \ -t 10000 \ -h string:x-canonical-private-synchronous:battery \ "Battery" "$1" } case "$BLOCK_BUTTON" in # ugly must do better 1) notify "$(inxi -B --extra -c 0 -y 1 | sed -e 's/^[ \t]*//')" ;; 3) notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')" ;; esac # Loop through all attached batteries. for battery in /sys/class/power_supply/BAT?*; do # If non-first battery, print a space separator. [ -n "${capacity+x}" ] && printf " " capacity="$(cat "$battery/capacity" 2>&1)" if [ "$capacity" -gt 90 ]; then status="󰁹 " elif [ "$capacity" -gt 60 ]; then status="󰁿 " elif [ "$capacity" -gt 40 ]; then status="󰁽 " elif [ "$capacity" -gt 10 ]; then status="󰁺 " else status="󰂎 " fi case "$(cat "$battery/status" 2>&1)" in Full) status="󱐋 " ;; Discharging) if [ "$capacity" -le 20 ]; then status="$status" color=1 fi ;; Charging) status="󰚥$status" ;; "Not charging") status=" " ;; Unknown) status="? $status" ;; *) exit 1 ;; esac echo "| $status$capacity% |" done