Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

63 lines
1.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/bin/bash
  2. source ~/.config/config.env
  3. ramp10=
  4. ramp20=
  5. ramp30=
  6. ramp40=
  7. ramp50=
  8. ramp60=
  9. ramp70=
  10. ramp80=
  11. ramp90=
  12. ramp100=
  13. ac_bat=
  14. ac=ﮣ
  15. if [ "$NO_BAT" = true ] ; then
  16. echo "^c#ebcb8b^$ac^d^"
  17. else
  18. export bat=$(cat /sys/class/power_supply/BAT0/capacity)
  19. export status=$(cat /sys/class/power_supply/BAT0/status)
  20. export plugged=$(cat /sys/class/power_supply/AC/online)
  21. tleft=$(acpi -b | sed -r 's/.* ([0-9]{2}:[0-9]{2}).*/\1/g')
  22. if [ -f "$XDG_CACHE_HOME/battery_tleft" ] && [ ! $(echo "$tleft" | grep "Full")]; then
  23. stats="$tleft"
  24. else
  25. stats="$bat%"
  26. fi
  27. if [[ $plugged == "1" ]]; then
  28. echo "^c#ebcb8b^$ac_bat^d^ $stats"
  29. elif [[ $bat -lt 10 ]]; then
  30. echo "^c#ebcb8b^$ramp10^d^ $stats"
  31. elif [[ $bat -lt 20 ]]; then
  32. echo "^c#ebcb8b^$ramp20^d^ $stats"
  33. elif [[ $bat -lt "30" ]]; then
  34. echo "^c#ebcb8b^$ramp30^d^ $stats"
  35. elif [[ $bat -lt "40" ]]; then
  36. echo "^c#ebcb8b^$ramp40^d^ $stats"
  37. elif [[ $bat -lt "50" ]]; then
  38. echo "^c#ebcb8b^$ramp50^d^ $stats"
  39. elif [[ $bat -lt "60" ]]; then
  40. echo "^c#ebcb8b^$ramp60^d^ $stats"
  41. elif [[ $bat -lt "70" ]]; then
  42. echo "^c#ebcb8b^$ramp70^d^ $stats"
  43. elif [[ $bat -lt "80" ]]; then
  44. echo "^c#ebcb8b^$ramp80^d^ $stats"
  45. elif [[ $bat -lt "90" ]]; then
  46. echo "^c#ebcb8b^$ramp90^d^ $stats"
  47. elif [[ $bat -le "100" ]]; then
  48. echo "^c#ebcb8b^$ramp100^d^ $stats"
  49. fi
  50. fi
  51. case $BLOCK_BUTTON in
  52. 1)
  53. if [ -f "$XDG_CACHE_HOME/battery_tleft" ]; then
  54. rm "$XDG_CACHE_HOME/battery_tleft"
  55. else
  56. touch "$XDG_CACHE_HOME/battery_tleft"
  57. fi
  58. ;;
  59. esac