From 8aa99de4025c5f1bf30d8e1baa2558ddb1b9554a Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Thu, 30 Mar 2023 21:42:20 +1030 Subject: [PATCH] minor uplifts --- .local/bin/bash-status-bat | 18 +++++++++--------- .local/bin/status-bat | 2 +- .local/bin/status-vol | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.local/bin/bash-status-bat b/.local/bin/bash-status-bat index b412cf7..6751e13 100755 --- a/.local/bin/bash-status-bat +++ b/.local/bin/bash-status-bat @@ -6,22 +6,22 @@ readarray -t batteries < <(upower -e | grep 'BAT') allstate="" -for battery in ${batteries[@]} +for battery in "${batteries[@]}" do - current=$(($current + $(upower -i "$battery" | grep -E "percentage" | sed 's/.*://' | sed 's/ *//' | sed 's/\%//'))) - state=$(upower -i "$battery" | grep -E "state" | sed 's/.*://' | sed 's/ *//') + current=$(("$current" + $(upower -i "$battery" | grep -E "percentage" | sed 's/.*://' | sed 's/ *//' | sed 's/\%//'))) + state=$(upower -i "$battery" | grep -E "state" | sed 's/.*://' | sed 's/ *//') - allstate=$allstate$state + allstate=$allstate$state done if [[ "$allstate" == *"discharging"* ]]; then - state="discharging" + state="discharging" elif [[ "$allstate" == *"charging"* ]]; then - state="charging" -elif [[ "$allstate" == "not-chargingnot-charging" || "$allstate" == "fully-chargedfully-charged" ]]; then - state="full" + state="charging" +elif [[ "$allstate" == "not-chargingnot-charging" || "$allstate" == "fully-chargedfully-charged" || "$allstate" == "not-charging" || "$allstate" == "fully-charged" ]]; then + state="full" else - state="N/A" + state="N/A" fi echo "$((current/${#batteries[@]}))% $state" diff --git a/.local/bin/status-bat b/.local/bin/status-bat index 6a53cc5..fede8f3 100755 --- a/.local/bin/status-bat +++ b/.local/bin/status-bat @@ -33,7 +33,7 @@ case $state in not-charging) icon=" " ;; - fully-charged) + fully-charged|full) icon=" " status="Full" ;; diff --git a/.local/bin/status-vol b/.local/bin/status-vol index 3828a39..b496d5b 100755 --- a/.local/bin/status-vol +++ b/.local/bin/status-vol @@ -5,7 +5,7 @@ vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" # If muted, print 🔇 and exit. -[ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit +[ "$vol" != "${vol%\[MUTED\]}" ] && echo " " && exit vol="${vol#Volume: }" @@ -21,9 +21,9 @@ vol="${vol##0}" case 1 in $((vol >= 70)) ) icon="" ;; - $((vol >= 30)) ) icon="" ;; - $((vol >= 1)) ) icon="" ;; - * ) echo " " && exit ;; +$((vol >= 30)) ) icon="" ;; +$((vol >= 1)) ) icon="" ;; +* ) echo " " && exit ;; esac echo "$icon $vol%"