Last active
August 29, 2015 14:01
-
-
Save komiyake/c33b30f4ffbdea3985d3 to your computer and use it in GitHub Desktop.
tmux-powerlineで複数のバッテリーが表示できるようにした。また、充電中かどうかも表示できる。使用にはacpiコマンドをインストールする必要がある。
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
HEART_FULL="♥" | |
HEART_EMPTY="♡" | |
CHARGING="☇" | |
run_segment() { | |
output=$(__cutinate) | |
if [ -n "$output" ]; then | |
echo "$output" | |
fi | |
} | |
__cutinate() { | |
acpi > .battery | |
while read res | |
do | |
if test `echo $res | cut -f1 -d"," | cut -f3 -d " "` = "Charging"; then | |
echo -n $CHARGING | |
elif test `echo $res | cut -f1 -d"%" | cut -f4 -d " "` -gt 50; then | |
echo -n $HEART_FULL | |
else | |
echo -n $HEART_EMPTY | |
fi | |
BATTERY=`echo $res | cut -f1 -d "%" | cut -f4 -d " "` | |
TIME=`echo $res | cut -f5 -d " " | cut -f4 -d " "` | |
echo -n " ${BATTERY}% ${TIME} " | |
done < .battery | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment