Switch all connected PulseAudio bluetooth devices to A2DP profile

for card in $(pacmd list-cards | grep 'name: ' | sed 's/.*<\(.*\)>.*/\1/'); do pacmd set-card-profile $card a2dp_sink; done
Tries to switch all audio devices to the A2DP profile for optimal sound quality. Useful for bluetooth speakers and headphones that always power up in HSP/HFP mode. Note however that this command is only a shorthand for the GUI, so it cannot fix stubborn BT controllers that leave your device stuck in HSP mode until a manual re-coupling.

By: lordtoran
2019-04-18 18:01:45

What Others Think

don't ever parse lines with `for' loop don't ever use `grep' before `sed' don't ever omit to quote variable expansion this is bash while read card; do pacmd set-card-profile "$card" a2dp_sink; done < <(pacmd list-cards | sed -n '/name:/s/.*<\(.*\)>.*/\1/p') this is POSIX pacmd list-cards | sed -n '/name:/s/.*<\(.*\)>.*/\1/p' | while read card; do pacmd set-card-profile "$card" a2dp_sink; done
daPeach · 126 weeks and 3 days ago
Bluetooth 5.0 https://eyelashextensionsatlantaga.com
geebranz · 18 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: