dotfiles/scripts/status/volstat
2024-02-21 22:18:46 -06:00

28 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# Fetch current audio level
# (in current default output)
# Get volume level
vol=$(amixer | grep "Playback" | 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 "Playback" | 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"