#!/bin/sh
# Fetch current mic levels
# (in current default Capture)

# Get volume levels
vol=$(amixer | grep "Capture" | grep -m 1 -o '[0-9]*[0-9]%')
vol="${vol%\%*}" # Remove percentage sign

# If device is off (muted), notify mute, print volume otherwise
if amixer scontents | grep "Capture" | grep -q "\[off\]"; then echo "󰍭 ──────────" && exit ; fi

# Define bar progress with volume
case 1 in
    $((vol >= 100)) ) bar="━━━━━━━━━━" ;;
    $((vol >= 90))  ) bar="━━━━━━━━━─" ;;
    $((vol >= 80))  ) bar="━━━━━━━━──" ;;
    $((vol >= 70))  ) bar="━━━━━━━───" ;;
    $((vol >= 60))  ) bar="━━━━━━────" ;;
    $((vol >= 50))  ) bar="━━━━━─────" ;;
    $((vol >= 40))  ) bar="━━━━──────" ;;
    $((vol >= 30))  ) bar="━━━───────" ;;
    $((vol >= 20))  ) bar="━━────────" ;;
    $((vol >= 10))  ) bar="━─────────" ;;
    $((vol >= 0))   ) bar="──────────" ;;
esac

# Print and notify
echo "󰍬 $bar"