Skip to content

Instantly share code, notes, and snippets.

@ZimbiX
Created April 14, 2015 16:30
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 ZimbiX/29a718613304013b8b6e to your computer and use it in GitHub Desktop.
Save ZimbiX/29a718613304013b8b6e to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Returns the number of Watts at which the battery is charging or discharging, to one decimal place
rate=`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'energy-rate:[ ]*[0-9\.]* W' | grep -o '[0-9\.]*'`
printf "%0.1f\n" $rate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment