8
[[ -n "$@" ]] && echo -e "$APP: $@" >&2
14
echo "$APP: audio switch control, version 0.1"
19
echo "Usage: $APP [OPTION]... COMMAND"
22
echo " --quiet Do not complain on error"
23
echo " -v, --version Display version information"
24
echo " -h, --help This message"
27
echo " on Switch audio routing on"
28
echo " off Switch audio routing off"
30
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
36
# parse command line args
37
PROGRAMARGS=`getopt -n "$APP" -l device:,quiet,version,help vh "$@"`
38
[[ $? != 0 ]] && exit 1
39
eval set -- "$PROGRAMARGS"
42
--quiet) QUIET=1; shift;;
43
-v|--version) version; exit 0;;
44
-h|--help) usage; exit 0;;
50
[[ -z "$1" ]] && die "you did not specify a command, see --help"
51
[[ -n "$2" ]] && die "too many arguments, see --help"
58
*) die "invalid comand, see --help";;
62
DEVICES=`grep -l edam /sys/bus/usb/devices/*/manufacturer | sed 's/\/[^\/]*$//'`
63
DEVICES=`for DIR in "$DEVICES"; do grep -li ba7f "$DIR"/idProduct; done | sed 's/\/[^\/]*$//'`
64
DEVICES=`for DIR in "$DEVICES"; do grep -li 03eb "$DIR"/idVendor; done | sed 's/\/[^\/]*$//'`
65
DEVICES=`for DIR in "$DEVICES"; do [[ -d "$DIR":1.0/tty ]] && echo "$DIR":1.0/tty/*; done | sed 's/^.*\///'`
67
[[ ${#TEMP[*]} -gt 1 ]] && die "more than one audio switch detetced, use --device"
71
[[ -z "$DEVICE" ]] && die "audio switch not found"
72
[[ -c /dev/"$DEVICE" ]] || die "audio switch device should be there, but isn't!"
75
echo $COMMAND > /dev/$DEVICE