123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/bin/bash
-
- . $(ffoom path)
-
- ffoo import pretty
-
-
- usage() {
- usage_is "up" \
- "down" \
- "flip" \
- "mute" \
- "unmute"
- }
-
-
- sound_is_muted() {
- #
- # At least one playback channel is muted
- #
- local master_status="$(amixer get Master)"
- echo "$master_status" \
- | grep "Playback channels" \
- | sed -e 's/.*: //; s/ - /\n/' \
- | while read chname
- do
- grep -e "^ *$chname" <<<"$master_status"
- done \
- | grep -qse '\[off\]$'
- }
-
- do_down() {
- #
- # turn volume down
- #
- amixer -q sset Master 5%-
- }
-
- do_flip() {
- #
- # mute or unmute
- #
- if sound_is_muted;
- then
- amixer -q sset Master unmute;
- else
- amixer -q sset Master mute;
- fi
- }
-
- do_mute() {
- #
- # mute
- #
- amixer -q sset Master mute
- }
-
- do_up() {
- #
- # turn volume up
- #
- amixer -q sset Master 5%+
- }
-
- do_unmute() {
- #
- # mute
- #
- amixer -q sset Master unmute
- }
-
-
- action=
- while true; do case "$1" in
- up) action=up; shift ;;
- down) action=down; shift ;;
- flip) action=flip; shift ;;
- mute) action=mute; shift ;;
- unmute) action=unmute; shift ;;
- "") break ;;
- *) usage ;;
- esac done
-
- debug "\$@='$@'"
- debug -v action
-
- case $action in
- up|down|flip|mute|unmute) do_$action ;;
- *) usage ;;
- esac
|