Created
July 9, 2020 05:17
-
-
Save andersx/ce95dc0fa5143bffd1caef2c1d59345d to your computer and use it in GitHub Desktop.
Toggle speakers/headphones for Creative Soundblasterx AE-5 on with amixer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Grep which device is Creative | |
AMIXEROUTPUT=$(aplay -l | grep -m1 Creative) | |
DEVICE=${AMIXEROUTPUT:5:1} | |
# Grep for connected headphones | |
OUTPUT=$(amixer -c $DEVICE sget "Output Select" | grep "Item0: 'Headphone'") | |
echo $AMIXEROUTPUT | |
echo "Device" $DEVICE | |
echo $OUTPUT | |
# If string was empty no headphones were connected | |
if [[ -z $OUTPUT ]]; then | |
amixer -c $DEVICE sset 'Output Select' 'Headphone' | |
# If there was a string, connect Line Out | |
else | |
amixer -c $DEVICE sset 'Output Select' 'Line Out' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment