From 7a51ea23eeea3590db6db18a3730d64427c2774d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20S=C3=A1nchez?= Date: Thu, 25 May 2017 00:21:30 -0500 Subject: [PATCH] Improvements in Atomic theme Operating system detection was added to show the percentage of the battery in the promt --- themes/atomic/atomic.theme.bash | 65 ++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/themes/atomic/atomic.theme.bash b/themes/atomic/atomic.theme.bash index 467e8c4c..ef90f06e 100644 --- a/themes/atomic/atomic.theme.bash +++ b/themes/atomic/atomic.theme.bash @@ -166,7 +166,48 @@ ___atomic_prompt_clock() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" } -___atomic_prompt_battery() { +case "$OSTYPE" in + cygwin*) ___atomic_prompt_battery() { + [ "${THEME_SHOW_BATTERY}" != "true" ] && return + batp=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*') + bats=$(echo porcent=$(WMIC Path Win32_Battery Get BatteryStatus /Format:List) | grep -o '[0-9]*') + + if [ "$batp" -gt 50 ]; then + color=$bold_green + elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then + color=$bold_yellow + elif [ "$batp" -lt 25 ]; then + color=$IRed + fi + + box="[|]" + [ "$bats" -eq 1 ] && info="-" + [ "$bats" -eq 2 ] && info="+" + info+=$batp + [ "$info" == "+100" ] && info="AC" + printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" + } ;; + msys*) ___atomic_prompt_battery() { + [ "${THEME_SHOW_BATTERY}" != "true" ] && return + batp=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*') + bats=$(echo porcent=$(WMIC Path Win32_Battery Get BatteryStatus /Format:List) | grep -o '[0-9]*') + + if [ "$batp" -gt 50 ]; then + color=$bold_green + elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then + color=$bold_yellow + elif [ "$batp" -lt 25 ]; then + color=$IRed + fi + + box="[|]" + [ "$bats" -eq 1 ] && info="-" + [ "$bats" -eq 2 ] && info="+" + info+=$batp + [ "$info" == "+100" ] && info="AC" + printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" + } ;; + darwin*) ___atomic_prompt_battery() { [ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] || [ "${THEME_SHOW_BATTERY}" != "true" ] && return batp=$(battery_percentage) @@ -183,7 +224,27 @@ ___atomic_prompt_battery() { info+=$batp [ "$info" == "+100" ] && info="AC" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" -} + } ;; + linux*) ___atomic_prompt_battery() { + [ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] || + [ "${THEME_SHOW_BATTERY}" != "true" ] && return + batp=$(battery_percentage) + if [ "$batp" -gt 50 ]; then + color=$bold_green + elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then + color=$bold_yellow + elif [ "$batp" -lt 25 ]; then + color=$IRed + fi + box="[|]" + ac_adapter_disconnected && info="-" + ac_adapter_connected && info="+" + info+=$batp + [ "$info" == "+100" ] && info="AC" + printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" + } ;; + *) echo "bt:" ;; +esac ___atomic_prompt_exitcode() { [ "${THEME_SHOW_EXITCODE}" != "true" ] && return