dotfiles/scripts/status/volstat
2024-02-04 19:01:27 -06:00

33 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
# Fetch current audio level
# (in current default output)
# Get volume level
vol=$(amixer | grep "Playback" | grep -o '[0-9]*[0-9]%' | head -n 1)
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 "󰖁 ──────────"
notify-send -u low --replace-id=10 "󰖁 Volume" "Mute" 2>/dev/null
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"
notify-send -u low --replace-id=10 "󰕾 Volume" "$bar" 2>/dev/null