Skip to content

Instantly share code, notes, and snippets.

@sbogacz
Last active March 13, 2018 03:41
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 sbogacz/e090322c8aa2b3e5e320d0f3ac1a87ad to your computer and use it in GitHub Desktop.
Save sbogacz/e090322c8aa2b3e5e320d0f3ac1a87ad to your computer and use it in GitHub Desktop.
WIP to get the unicode character and the color code for conky
#!/bin/bash
ICON_MODE=false
COLOR_MODE=false
STATUS=`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state" | awk '{print $2}'`
STATUS_ICON='\xF0\x9F\x94\x8C'
if [[ "$STATUS" != "charging" && "$STATUS" != "fully-charged" ]]; then
STATUS_ICON='\xF0\x9F\x94\x8B'
fi
COLOR="#00ff00"
if [[ "$STATUS" != "charging" && "$STATUS" != "fully-charged" ]]; then
COLOR="#00ff00"
fi
PRINT_COLOR='\033[0;32m'
if [[ "$STATUS" != "charging" && "$STATUS" != "fully-charged" ]]; then
PRINT_COLOR='\033[0;31m'
fi
while test $# -gt 0; do
case "$1" in
-i|--icon-mode)
echo "$STATUS_ICON"
exit 0
;;
-c|--color-mode)
echo "$COLOR"
exit 0
;;
*)
echo -e "${PRINT_COLOR}$STATUS_ICON"
break
;;
esac
done
echo -e "${PRINT_COLOR}$STATUS_ICON"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment