Skip to content

Instantly share code, notes, and snippets.

@janernsting
Last active December 10, 2015 19:48
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 janernsting/4484127 to your computer and use it in GitHub Desktop.
Save janernsting/4484127 to your computer and use it in GitHub Desktop.
battery drain notification for byobu
#!/bin/sh -e
for bat in /sys/class/power_supply/*; do
status=""; drain=""
if [ -r "$bat/power_now" ] && [ -r "$bat/status" ]; then
drain=`cat "$bat/power_now"`
status=`cat "$bat/status"`
[ $status = "Discharging" ] && break
fi
done
if [ "$status" = "Discharging" ]; then
echo `awk 'BEGIN { printf "%.2fW", "'$drain'"/1000000 }'`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment