From 970546855b4bdda5e3d40ece2fd1cbef19216146 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 5 Dec 2014 01:22:36 +0300 Subject: [PATCH] update prompt --- zsh/prompt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/zsh/prompt b/zsh/prompt index 1cfcb92..66d8e1a 100644 --- a/zsh/prompt +++ b/zsh/prompt @@ -19,15 +19,23 @@ fi precmd() { # battery charge function batcharge { - bat_perc=$(acpi | awk {'print $4;'} | sed -e "s/\s//" -e "s/%.*//") - if [[ ${bat_perc} < 15 ]]; then - col="%{$fg_bold[red]%}" - elif [[ ${bat_perc} < 50 ]]; then - col="%{$fg_bold[yellow]%}" + local _bat_perc=0 + local _num=0 + local _bat + for _bat in /sys/class/power_supply/BAT*; do + let "_bat_perc += $(cat ${_bat}/capacity)" + let "_num += 1" + done + _bat_perc=$((${_bat_perc}/${_num})) + local _col + if [[ ${_bat_perc} < 15 ]]; then + _col="%{$fg_bold[red]%}" + elif [[ ${_bat_perc} < 50 ]]; then + _col="%{$fg_bold[yellow]%}" else - col="%{$fg_bold[green]%}" + _col="%{$fg_bold[green]%}" fi - echo "%{$fg_bold[white]%}["$col$bat_perc"%{$fg_bold[white]%}%%]%{$reset_color%}" + echo "%{$fg_bold[white]%}["${_col}${_bat_perc}"%{$fg_bold[white]%}%%]%{$reset_color%}" } # last command returncode="%(?.%{$fg[green]%}.%{$fg[red]%})%?%{$resetcolor%}"