#!/usr/bin/env bash
#
# Read volume status in FreeBSD
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SLEEP_INTERVAL=${SLEEP_INTERVAL:-30}
while true; do
current_vol_mixer=$(mixer -S vol)
vol_left=$(cut -d ':' -f 2 <<<"$current_vol_mixer")
vol_right=$(cut -d ':' -f 3 <<<"$current_vol_mixer")
avg_vol=$(((vol_left + vol_right) / 2))
tooltip="$(mixer)"
class=""
icon=""
if [ $avg_vol -eq 0 ]; then
icon="🔇"
elif [ $avg_vol -le 50 ]; then
icon="🔉"
else
icon="🔊"
fi
jq --unbuffered --compact-output <