bar-battery.sh 584 B

123456789101112131415161718
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # battery=$(acpi | cut -d " " -f3-5 | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/❓/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g" | tail -n1)
  4. battery=$(acpi | cut -d " " -f3-4 | tail -n1)
  5. [[ -z $battery ]] && exit
  6. echo -e "BAT: ${battery}"
  7. # # https://vivien.github.io/i3blocks/
  8. # BAT=$(acpi -b | grep -E -o '[0-9][0-9]?%')
  9. # # Full and short texts
  10. # echo "Battery: $BAT"
  11. # echo "BAT: $BAT"
  12. # # Set urgent flag below 5% or use orange below 20%
  13. # [ ${BAT%?} -le 5 ] && exit 33
  14. # [ ${BAT%?} -le 20 ] && echo "#FF8000"