clozed2u
10/24/2015 - 5:45 PM

Show battery status on mac os x

Show battery status on mac os x

#!/bin/bash

percent=$(pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f1 -d'%')

args=("$@")
if [ "${args[0]}" == "debug" ]; then
  echo "$percent"
fi

if [ "$percent" -gt "80" ]; then
  result="★ ★ ★ ★ ★ "
elif [ "$percent" -gt "60" ]; then
  result="★ ★ ★ ★ ☆ "
elif [ "$percent" -gt "40" ]; then
  result="★ ★ ★ ☆ ☆ "
elif [ "$percent" -gt "20" ]; then
  result="★ ★ ☆ ☆ ☆ "
elif [ "$percent" -gt "0" ]; then
  result="★ ☆ ☆ ☆ ☆ "
fi

echo "$result"