sb-battery (1170B)
1 #!/bin/sh 2 3 # Prints all batteries, their percentage remaining and an emoji corresponding 4 # to charge status (P for plugged up, D for discharging on battery, etc.). 5 6 case $BLOCK_BUTTON in 7 3) notify-send "Battery module" "D: discharging 8 N: not charging 9 S: stagnant charge 10 P: charging 11 :3: charged 12 uwaa!: battery very low! 13 - Scroll to change adjust xbacklight." ;; 14 4) xbacklight -inc 10 ;; 15 5) xbacklight -dec 10 ;; 16 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; 17 esac 18 19 # Loop through all attached batteries and format the info 20 for battery in /sys/class/power_supply/BAT?*; do 21 # If non-first battery, print a space separator. 22 [ -n "${capacity+x}" ] && printf " " 23 # Sets up the status and capacity 24 case "$(cat "$battery/status" 2>&1)" in 25 "Full") status=":3 " ;; 26 "Discharging") status="D " ;; 27 "Charging") status="P " ;; 28 "Not charging") status="N " ;; 29 "Unknown") status="idk " ;; 30 *) exit 1 ;; 31 esac 32 capacity="$(cat "$battery/capacity" 2>&1)" 33 # Will make a warn variable if discharging and low 34 [ "$status" = "D " ] && [ "$capacity" -le 5 ] && warn="uwaa! " 35 # Prints the info 36 printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn 37 done && printf "\\n"