Last active
March 13, 2018 03:41
-
-
Save sbogacz/e090322c8aa2b3e5e320d0f3ac1a87ad to your computer and use it in GitHub Desktop.
WIP to get the unicode character and the color code for conky
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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