Change default audio output device

Archived topics about LMDE 1 and LMDE 2
Locked
styounes

Change default audio output device

Post by styounes »

First off let me say that, after distro-hopping for a while, I have found, in my opinion, the best Linux distribution ever in Linux mint. As a hobbyist programmer, I can definitely say it is not easy to make great software. So hats off to the developers!

Now on to the question: see the title. I am running Linux mint Debian Edition (x64) and have USB headphones. For the life of me, I cannot change the default sound device to this headset. It detects correctly (shows up in "Volume Control") and I can output to the device via VLC (requires changing the settings in that application). However, I would like to change this device to default audio output device globally. I am using MATE desktop with Compiz Window Manager (Desktop Cube! :D ). I apologize if I am missing something obvious, but I have searched to no avail for quite some time. Thanks for your help!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
cmost
Level 4
Level 4
Posts: 416
Joined: Tue Sep 18, 2007 7:36 am
Location: Newport, Kentucky

Re: Change default audio output device

Post by cmost »

I'm no PulseAudio expert, but have you tried controlling PulseAudio through the command line using pacmd and pactl commands?
For options see man pages (pacmd: http://linux.die.net/man/1/pacmd, pactl: http://linux.die.net/man/1/pactl
or the wiki at PulseAudio: http://mpd.wikia.com/wiki/PulseAudio

Here are some basic commands to get you started. Once you figure out what you need, then perhaps a simple shell script that runs on log-in will set your preferences automatically.

Code: Select all

pacmd list-sinks to list name or index number of possible sinks

pacmd set-default-sink "SINKNAME" to set the default output sink

pacmd set-default-source "SOURCENAME" to set the default input

pacmd set-sink-volume index volume

pacmd set-source-volume index volume for volume control (0 = Mute, 65536 = 100%)
Changing the output sink through the command line interface can only take effect if stream target device reading is disabled. This can be done by editing the corresponing line in

Code: Select all

sudo gedit /etc/pulse/default.pa

Code: Select all

load-module module-stream-restore restore_device=false
Dual Intel Xeon 3.6 GHz, 24 Cores
192 GB DDR3 RAM
AMD Radeon Pro WX 7100
styounes

Re: Change default audio output device

Post by styounes »

Thank you very much! Your fix works (script writing time! :D ). Only a single thing is keeping it from working perfectly: the volume up and down keys on my keyboard and headset (that produce the little animation demonstrating volume) do not affect the volume at all. This may be beyond the bounds of PulseAudio (possibly OS level). Do you know how to fix this?
zaq.hack

Re: Change default audio output device

Post by zaq.hack »

My bash-fu is not the best, but the following script works based on the above information. I have struggled with Pulse Audio too many times to mention, but this is the first time Google revealed a remedy that I could script. I saved this as "fix-audio.sh" and it has to be run by your X user (not root, unless you are running X as root, in which case, why are you using Mint?).

Code: Select all

#!/bin/bash

### A stab at fixing Pulse Audio settings when you find your Mint has gone mute ...
### version 1.0 - 2012-09-28
###
### The most common problem is that the audio sink defaults to the HDMI on my laptop.
### As such, you will see "grep" statements at the end of "ASINK" and "ASOURCE" lines.
### Run the script without modification, first - you will get a list of audio "sinks"
### (aka outputs) and "sources" (aka inputs). If you can tell which ones you would
### like to use on a regular basis, modify the part of the line AFTER the "awk"
### statement to specify them.

# List audio sinks (outputs)
echo Avalable sinks:
pacmd list-sinks | grep name:

# Replace to the right of the marker to specify your audio sinks (outputs)         \/
ASINK=`pacmd list-sinks | grep name: | awk ' { print substr($2,2,length($2)-2) } ' | grep analog`
echo Default sink set to $ASINK
pacmd set-default-sink $ASINK
echo
pacmd set-sink-volume $ASINK 65000
echo
echo ------------------------------

# List audio sources (inputs)
echo Available sources:
pacmd list-sources | grep name:

# Replace to the right of the marker to specify your audio sources (inputs)            \/
ASOURCE=`pacmd list-sources | grep name: | awk ' { print substr($2,2,length($2)-2) } ' | grep -v monitor | grep analog`
echo Default source set to $ASOURCE
pacmd set-default-source $ASOURCE
echo
pacmd set-source-volume $ASOURCE 65000
echo
Running properly, the output on my laptop looks like this:

Code: Select all

Avalable sinks:
	name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	name: <combined>
Default sink set to alsa_output.pci-0000_00_1b.0.analog-stereo
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> 
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> 
------------------------------
Available sources:
	name: <alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor>
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor>
	name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
	name: <combined.monitor>
Default source set to alsa_input.pci-0000_00_1b.0.analog-stereo
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> 
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> 
Locked

Return to “LMDE Archive”