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>
13 lines
388 B
Bash
Executable file
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
|