SHARE
TWEET

Untitled

a guest Feb 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. # Give a battery name (e.g. BAT0) as an argument.
  3.  
  4. # get xresources colors
  5. for x in "$(xrdb -query | grep color | sed "s/.*\./export /g;s/:\s*/=\"/g;s/$/\"/g" | sed 's/\*//g')"; do
  6.     eval "$x";
  7. done
  8.  
  9. capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
  10. status=$(cat /sys/class/power_supply/"$1"/status)
  11.  
  12. if [ "$capacity" -ge 75 ]; then
  13.     color="$color10"
  14. elif [ "$capacity" -ge 50 ]; then
  15.     color="$color15"
  16. elif [ "$capacity" -ge 25 ]; then
  17.     color="$color11"
  18. else
  19.     color="$color9"
  20.     warn="❗"
  21. fi
  22.  
  23. [ -z $warn ] && warn=" "
  24.  
  25. [ "$status" = "Charging" ] && color="$color15"
  26.  
  27. printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top