minor uplifts

This commit is contained in:
Solomon Laing 2023-03-30 21:42:20 +10:30
parent 5d74d499e1
commit 8aa99de402
3 changed files with 14 additions and 14 deletions

View File

@ -6,22 +6,22 @@ readarray -t batteries < <(upower -e | grep 'BAT')
allstate="" allstate=""
for battery in ${batteries[@]} for battery in "${batteries[@]}"
do do
current=$(($current + $(upower -i "$battery" | grep -E "percentage" | sed 's/.*://' | 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/ *//') state=$(upower -i "$battery" | grep -E "state" | sed 's/.*://' | sed 's/ *//')
allstate=$allstate$state allstate=$allstate$state
done done
if [[ "$allstate" == *"discharging"* ]]; then if [[ "$allstate" == *"discharging"* ]]; then
state="discharging" state="discharging"
elif [[ "$allstate" == *"charging"* ]]; then elif [[ "$allstate" == *"charging"* ]]; then
state="charging" state="charging"
elif [[ "$allstate" == "not-chargingnot-charging" || "$allstate" == "fully-chargedfully-charged" ]]; then elif [[ "$allstate" == "not-chargingnot-charging" || "$allstate" == "fully-chargedfully-charged" || "$allstate" == "not-charging" || "$allstate" == "fully-charged" ]]; then
state="full" state="full"
else else
state="N/A" state="N/A"
fi fi
echo "$((current/${#batteries[@]}))% $state" echo "$((current/${#batteries[@]}))% $state"

View File

@ -33,7 +33,7 @@ case $state in
not-charging) not-charging)
icon=" " icon=" "
;; ;;
fully-charged) fully-charged|full)
icon=" " icon=" "
status="Full" status="Full"
;; ;;

View File

@ -5,7 +5,7 @@
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
# If muted, print 🔇 and exit. # If muted, print 🔇 and exit.
[ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit [ "$vol" != "${vol%\[MUTED\]}" ] && echo " " && exit
vol="${vol#Volume: }" vol="${vol#Volume: }"
@ -21,9 +21,9 @@ vol="${vol##0}"
case 1 in case 1 in
$((vol >= 70)) ) icon="" ;; $((vol >= 70)) ) icon="" ;;
$((vol >= 30)) ) icon="" ;; $((vol >= 30)) ) icon="" ;;
$((vol >= 1)) ) icon="" ;; $((vol >= 1)) ) icon="" ;;
* ) echo " " && exit ;; * ) echo " " && exit ;;
esac esac
echo "$icon $vol%" echo "$icon $vol%"