Skip to content

Instantly share code, notes, and snippets.

@komiyake
Last active August 29, 2015 14:01
Show Gist options
  • Save komiyake/c33b30f4ffbdea3985d3 to your computer and use it in GitHub Desktop.
Save komiyake/c33b30f4ffbdea3985d3 to your computer and use it in GitHub Desktop.
tmux-powerlineで複数のバッテリーが表示できるようにした。また、充電中かどうかも表示できる。使用にはacpiコマンドをインストールする必要がある。
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