sxmo-utils/scripts/core/sxmo_audiocurrentdevice.sh
Clayton Craft 2d9740f252 sxmo_audio*: properly set vars with default values if they are unset
A mistake from implementing this resulted in the shell trying to expand
the 'word' part (e.g. "Line Out"), when the var was unset or null.
Obviously those are are strings and not expandable.

Signed-off-by: Anjandev Momi <anjan@momi.ca>
2021-04-24 01:14:55 -04:00

13 lines
388 B
Bash
Executable file

#!/usr/bin/env sh
SPEAKER=${SPEAKER:-"Line Out"}
HEADPHONE=${HEADPHONE:-"Headphone"}
EARPIECE=${EARPIECE:-"Earpiece"}
audiodevice() {
amixer sget "$EARPIECE" | grep -qE '\[on\]' && echo "$EARPIECE" && return
amixer sget "$HEADPHONE" | grep -qE '\[on\]' && echo "$HEADPHONE" && return
amixer sget "$SPEAKER" | grep -qE '\[on\]' && echo "$SPEAKER" && return
echo "None"
}
audiodevice