summaryrefslogtreecommitdiff
path: root/dot/local/bin/amixer-enable-mic
blob: 38d97c78a76ca90ef2dfbc2a552a33c6a3a6f571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

SETME=${1:-100%}
SETME_BOOST=${2:-50%}

amixer()
{
    set -- amixer "$@"
    if [ "$VERBOSE" ]; then
        printf "+ %s\n" "$*" >&2
    fi
    command "$@"
}

enable_recording()
{
  local DEV="$1"
  amixer -D "$DEV" controls | (
    IFS=,
    while read a b c _; do
      case "${c#name=}" in
        *Boost*)
          amixer -D "$DEV" cset "$a,$b,$c" "$SETME_BOOST";;
        \'Capture\ Channel\ Map\') ;;
        *Capture*)
          amixer -D "$DEV" cset "$a,$b,$c" "$SETME";;
      esac
    done
  )
}

hardware_devices()
{
  arecord -L |
    while IFS= read line; do
      case "$line" in hw:*)
        dev=${line##*DEV=}
        echo hw:${dev%%,*}
        ;;
      esac
    done
}

for dev in default $(hardware_devices); do
  enable_recording $dev
done