Skip to content

Instantly share code, notes, and snippets.

@coreymwamba
Created January 27, 2016 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymwamba/00b0d32cad802e494a59 to your computer and use it in GitHub Desktop.
Save coreymwamba/00b0d32cad802e494a59 to your computer and use it in GitHub Desktop.
Batteries. Laptops. Indicators. The eternal struggle. Conky tells you the percentage of the battery; acpi gives you a long string and an estimated time. This script, if used in Conky, will give you both.
#!/bin/bash
eval $(acpi -b | sed "s/Battery 0: //g" |sed "s/,//g"| awk 'BEGIN {FS=" "}; {print "ch="$1, "percent="$2, "countdown="substr($3,0,5)}')
case $ch in
Discharging)
sign="-"
;;
Unknown)
sign="~"
;;
Charging)
sign="+"
esac
echo $percent $sign$countdown
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment