summaryrefslogtreecommitdiff
path: root/plugins/battery/battery.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/battery/battery.plugin.zsh')
-rw-r--r--plugins/battery/battery.plugin.zsh14
1 files changed, 7 insertions, 7 deletions
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index 014bb15dd..8f398cfb3 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -64,15 +64,15 @@ if [[ "$OSTYPE" = darwin* ]] ; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
-elif [[ $(uname) == "Linux" ]] ; then
+elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() {
- ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
+ ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
}
function battery_pct() {
if (( $+commands[acpi] )) ; then
- echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
+ echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')"
fi
}
@@ -85,14 +85,14 @@ elif [[ $(uname) == "Linux" ]] ; then
}
function battery_time_remaining() {
- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
- echo $(acpi | cut -f3 -d ',')
+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
+ echo $(acpi 2>/dev/null | cut -f3 -d ',')
fi
}
function battery_pct_prompt() {
b=$(battery_pct_remaining)
- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
+ if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
if [ $b -gt 50 ] ; then
color='green'
elif [ $b -gt 20 ] ; then
@@ -100,7 +100,7 @@ elif [[ $(uname) == "Linux" ]] ; then
else
color='red'
fi
- echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
+ echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
else
echo "∞"
fi