diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2009-01-30 15:46:31 +0100 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2009-01-30 15:46:31 +0100 |
commit | 2e095258f79a96b4ba2c495c244a58fd9e9638ad (patch) | |
tree | 1ae75c72e30464aabe2f56c6253c732de3bf841c | |
parent | d7d775b9e6629105bf711527f4404b8350bade2d (diff) | |
parent | 87b805fedb4b677fce27f87155d0be02f1bd62e6 (diff) |
Merge branch 'master' of /work/repos/zdotdir
-rw-r--r-- | 12_Prompts.zsh | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 43f1304..8a8d5d1 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -138,42 +138,39 @@ update_prompt() if [ -e /proc/pmu/battery_0 ] then [ "$DEBUG" = "yes" ] && echo -n " Battery..." - ## Time - BATTERY_TIME=$(grep "^time rem" /proc/pmu/battery_0 | cut -c14- ) - BATTERY=$(( $BATTERY_TIME / 3600 )) - BATTERY=$BATTERY"h"$(( ($BATTERY_TIME - ( $BATTERY * 3600 )) / 60 ))"m" - BATTERYTMP="-"$BATTERY - BATTERYSIZE=${#BATTERYTMP} - - BATTERYCHARGING=$(grep "^current" /proc/pmu/battery_0 | cut -c14- ) - if [ $BATTERYCHARGING -gt 0 ] + + POWERADAPTER=$(grep "^AC Power" /proc/pmu/info | cut -c26) + + typeset -A battery + battery[remaining]=$(grep "^time rem" /proc/pmu/battery_0 | cut -c14- ) + battery[remain_hrs]=$(( $battery[remaining] / 3600 )) + battery[remain_min]=$(( ($battery[remaining] - ( $battery[remain_hrs] * 3600 )) / 60 )) + [ "$battery[remain_min]" -lt 10 ] && battery[remain_min]="0"$battery[remain_min] + battery[remains]=$battery[remain_hrs]"h"$battery[remain_min] + + BATTERYSIZE=$(( ${#battery[remains]} + 1 )) + + battery[load]=$(grep "^current" /proc/pmu/battery_0 | cut -c14- ) + + if [ $POWERADAPTER -ne 0 ] then - BATTERY="$C_$battery_colors[charging]$_C"$BATTERY - BATTERY="$SEPARATOR$BATTERY" + battery[color]="charging" + if [ $battery[load] -eq 0 ] + then + ## Battery full + BATTERYSIZE=2 + battery[remains]="⚡" + fi else - if [ $BATTERYCHARGING -lt 0 ] + if [ $battery[remaining] -lt 659 ] then - if [ $BATTERY_TIME -lt 659 ] - then - BATTERY="$C_$battery_colors[critical]$_C"$BATTERY - else - BATTERY="$C_$battery_colors[uncharging]$_C"$BATTERY - fi - BATTERY="$SEPARATOR$BATTERY" + battery[color]="critical" else - ## Battery full - BATTERY=$(grep "^AC Power" /proc/pmu/info | cut -c26) - if [ $BATTERY -ne 0 ] - then - BATTERY="⚡" - BATTERY="$SEPARATOR$BATTERY" - BATTERYSIZE=2 - else - BATTERY="" - BATTERYSIZE=0 - fi + battery[color]="uncharging" fi fi + BATTERY=$C_$prompt_colors[bar]$_C"-"$C_$battery_colors[$battery[color]]$_C"$battery[remains]" + unset battery [ "$DEBUG" = "yes" ] && echo else |