Skip to content

Instantly share code, notes, and snippets.

@schtibe
Last active December 15, 2015 01:49
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 schtibe/5182679 to your computer and use it in GitHub Desktop.
Save schtibe/5182679 to your computer and use it in GitHub Desktop.
Awesome battery widget updater
#!/bin/bash
while true ; do
state=`acpi -b`
percentage=`echo $state | grep -oP '\d+(?=%)'`
color='green'
echo $state | grep 'Discharging' && [[ $percentage -lt 15 ]] && color='red'
echo $state | grep 'Discharging' && [[ $percentage -gt 15 ]] && color='yellow'
text="<span foreground=\"$color\">$state</span>"
echo "bat_text:set_markup('$text')" | awesome-client
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment