4

I have my speakers plugged in to the Line Out jack. When I plug my headphones into the front headphone jack, the speakers are muted and sound is played in my headphones, as expected. However, when I open up pavucontrol and manually select to send sound to Line Out (which is listed as unplugged) it mutes the headphones (as expected) but does NOT play audio out the speakers.

I've tried many different permutations of pactl and pacmd, with set-sink-port and other commands, and every time, either nothing changes, or both the speakers and headphones are silent, as they are when I try to do it with pavucontrol.

TL;DR; I want to be able to switch between headphones and speakers while both are plugged in, but the speakers are ALWAYS silent when my headphones are plugged in.

I'm running up-to-date Fedora 23 with the KDE 5 desktop.

  • in alsamixer set auto-mute to enabled ---problem solved – linuxdev2013 Mar 9 '16 at 18:22
  • @linuxdev2013 I sure don't see any auto-mute option in alsamixer.... – BenjiWiebe Mar 9 '16 at 23:59
8
  1. Open up alsamixer. Then press F6 to select your sound card, most likely ending with PCH.
  2. Scroll right till you find the Auto-Mute option.
  3. Press up or down arrow to disable it. Press Esc to quit alsamixer. alsamixer settings

Use the following script to automate it.

#!/bin/sh

NAME=$(basename -- "$0")

command -v amixer >/dev/null 2>&1 || { echo >&2 "amixer not installed"; exit 1; }
command -v pacmd >/dev/null 2>&1 || { echo >&2 "pacmd not installed"; exit 1; }

amixer -c1 sset "Auto-Mute Mode" Disabled > /dev/null

if [ -z $1 ]; then
  echo -e "Usage:\nFront Speakers\t: $NAME 0\t\nHeadphones\t: $NAME 1\nBoth Speakers\t: $NAME 2"
  exit 1
elif [ $1 -eq 0 ] 2> /dev/null; then
  pacmd set-sink-port 1 analog-output-lineout
  amixer -c1 set Headphone 0% > /dev/null
  amixer -c1 set Front 100% > /dev/null
elif [ $1 -eq 1 ] 2> /dev/null; then
  pacmd set-sink-port 1 analog-output-headphones
  amixer -c1 set Front 0% > /dev/null
  amixer -c1 set Headphone 100% > /dev/null
elif [ $1 -eq 2 ] 2> /dev/null; then
  pacmd set-sink-port 1 analog-output-headphones
  amixer -c1 set Front 100% > /dev/null
  amixer -c1 set Headphone 100% > /dev/null
else
  echo -e "Invalid argument"
  exit 1
fi

This assumes that the card you are using is numbered 1. Also, it assumes that your PulseAudio ports are named analog-output-lineout and analog-output-headphones. Save it as something like speakers.sh and chmod to set execute bit.

Run speakers.sh 1 for Headphones and speakers.sh 0 for Speakers.

  • 1
    Wait...it doesn't quite work. Now audio plays out both, when headphones are chosen. i.e. it always plays out of speakers regardless of whether Line Out or Headphones are selected. – BenjiWiebe Apr 9 '16 at 19:49
  • @BenjiWiebe You could always mute the speakers through alsamixer. – Vishal Biswas Apr 10 '16 at 8:24
  • Yes I could, but I don't want to have so many steps needed...I wish I could just quickly and easily toggle between two outputs! – BenjiWiebe Apr 11 '16 at 14:06
  • check main post for automation script – Vishal Biswas Apr 12 '16 at 6:27
  • Thank you for answer , it saves me from some headaches . – EGurelli Feb 19 '18 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.