helm/base/arch-desktop/bin/vol

26 lines
658 B
Bash
Executable file

#!/usr/bin/env bash
if (($# == 0)); then
data=$(amixer get Master)
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
state=$(echo "$data" | grep '\[on\]')
[[ -n $state ]] && echo $vol || echo 0
exit
fi
case $1 in
[0-9]*) amixer set Master $1 ;;
[+-]) amixer set Master 5%$1 ;;
*mute) amixer set Master $1 ;;
toggle) amixer set Master toggle ;;
*) >&2 echo "Invalid command"
exit 1
;;
esac
# community/xosd
if command -v osd_cat >/dev/null; then
killall -9 -q osd_cat &>/dev/null
osd_cat --font="10x20" --delay=2 --color=white --align=center --pos=bottom --barmode=percentage --percentage $($0) &
fi