Skip to content

Instantly share code, notes, and snippets.

@vinbarnes
Forked from davidcelis/zelda-battery.sh
Created December 18, 2012 08:41
Show Gist options
  • Save vinbarnes/4326193 to your computer and use it in GitHub Desktop.
Save vinbarnes/4326193 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Slight modification to the original: https://gist.github.com/4323782
# This uses `cut` because it's Zelda, Link wouldn't use perl! He cuts
# with his sword.
#
# Works best with blinking text; the last heart will blink
# when you have less than 25% of your battery life remaining.
BATTERY="$(pmset -g ps | tail -1 | cut -f 2 |cut -f 1 -d ';' | cut -f 1 -d '%')"
if [[ $BATTERY -lt 25 ]]; then
printf "\e[5;31m♥\e[0;31m♡♡\e[0m\n"
elif [[ $BATTERY -lt 50 ]]; then
printf "\e[31m♥♡♡\e[0m\n"
elif [[ $BATTERY -lt 75 ]]; then
printf "\e[31m♥♥♡\e[0m\n"
else
printf "\e[31m♥♥♥\e[0m\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment