#!/usr/bin/env bash # Display the current battery status. # requires joypixels font in dwm config.def.h # This is updated by signal 2, so 2 + 34 = # kill -36 $(pidof dwmblocks) or # pkill -RTMIN+2 dwmblocks # 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" fi ;; "Charging") status="🔌$status" ;; "Not charging") status="â™ģ" ;; "Unknown") status="? $status" ;; *) exit 1 ;; esac echo -e " $status $capacity% ┊" done