dotfiles

My dotfiles
git clone https://giovanniamaral.com/git/dotfiles
Log | Files | Refs | README | LICENSE

sb-volume (469B)


      1 #!/bin/sh
      2 # SPDX-License-Identifier: GPL-3.0-or-later
      3 
      4 volume="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
      5 
      6 [ "$volume" != "${volume%\[MUTED\]}" ] && echo 🔇 && exit
      7 
      8 volume="${volume#Volume: }"
      9 
     10 split() {
     11 	IFS=$2
     12 	set -- $1
     13 	printf '%s' "$@"
     14 }
     15 
     16 volume="$(printf "%.0f" "$(split "$volume" ".")")"
     17 
     18 case 1 in
     19 	$((volume >= 70)) ) icon="🔊" ;;
     20 	$((volume >= 30)) ) icon="🔉" ;;
     21 	$((volume >= 1)) ) icon="🔈" ;;
     22 	* ) echo 🔇 && exit ;;
     23 esac
     24 
     25 echo "$icon $volume%"