dwm-bar for archlinux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
804 B

  1. #!/bin/sh
  2. # A dwm_bar function to read the battery level and status
  3. # Joe Standring <git@joestandring.com>
  4. # GNU GPLv3
  5. dwm_battery () {
  6. # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1
  7. CHARGE=$(cat /sys/class/power_supply/BAT0/capacity)
  8. STATUS=$(cat /sys/class/power_supply/BAT0/status)
  9. printf "%s" "$SEP1"
  10. if [ "$IDENTIFIER" = "" ]; then
  11. if [ "$STATUS" = "Charging" ]; then
  12. printf "🔌 %s%% %s" "$CHARGE" "$STATUS"
  13. else
  14. printf "🔋 %s%% %s" "$CHARGE" "$STATUS"
  15. fi
  16. else
  17. if [ "$STATUS" = "Charging" ]; then
  18. printf " %s%%" "$CHARGE"
  19. else
  20. printf " %s%%" "$CHARGE"
  21. #printf "BAT %s%% %s" "$CHARGE" "$STATUS"
  22. fi
  23. fi
  24. printf "%s\n" "$SEP2"
  25. }
  26. dwm_battery