From 729ef2847d82122a753bf1c9eaaad357aa50ae80 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Tue, 29 Nov 2022 16:01:21 +1030 Subject: [PATCH] updated volume script, now using pipewire instead of pulseaudio --- scripts/status-vol | 57 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/scripts/status-vol b/scripts/status-vol index 67a23dc..5d4d71e 100755 --- a/scripts/status-vol +++ b/scripts/status-vol @@ -1,36 +1,27 @@ #!/bin/sh -base03=#002b36 -base02=#073642 -base01=#586e75 -base00=#657b83 -base0=#839496 -base1=#93a1a1 -base2=#eee8d5 -base3=#fdf6e3 -yellow=#b58900 -orange=#cb4b16 -red=#dc322f -magenta=#d33682 -violet=#6c71c4 -blue=#268bd2 -cyan=#2aa198 -green=#859900 +# Prints the current volume or  if muted. -color=$cyan -volume="$(amixer sget Master | grep 'Front Left')" -if [ "${volume}" = "${volume%\[off\]*}" ] -then - volume="${volume#*\[}" - status="${volume%%\%\]*}" - case $((status/50)) in - 0) icon="" ;; # fa-volume-down f027 - 1) icon="" ;; # fa-volume-up f028 - *) icon=""; color=$orange ;; # fa-volume-up f028 - esac -else - status=MUTE - color=$red - icon="" # fa-volume-off f026 -fi -echo "$icon $status" +vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" + +# If muted, print 🔇 and exit. +[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit + +vol="${vol#Volume: }" +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} +vol="$(split "$vol" ".")" +vol="${vol##0}" + +case 1 in + $((vol >= 70)) ) icon="" ;; + $((vol >= 30)) ) icon="" ;; + $((vol >= 1)) ) icon="" ;; + * ) echo  && exit ;; +esac + +echo "$icon $vol%"