неделя, 13 август 2017 г.

How to switch between PulseAudio outputs with a button

I have horrible problems with my audio, due to a faulted audio jack. Basically what happens is that the PulseAudio keeps on switching between Headphones (which are not plugged in, but it thinks they are) and the Speakers. So what I decided to do is to put a shortcut on my panel to the file:
change_to_speakers.sh with the content:
#!/bin/bash
pactl set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-speaker

then I created a .desktop file with the content:
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Name=Speakers
Type=Application
Comment=Speakers
Exec="~/scripts/change_to_speaker.sh"
Icon=
GenericName=Speakers

After giving permission to run to the sh file with:
$chmod+x change_to_speaker.sh
I can switch to the speakers with just one click. Of course, that doesn't help with my faulty jack but at least makes the situation one idea more bearable.
They say you can also edit:
/etc/pulse/default.pa to: load-module module-stream-restore restore_device=false
to turn off the automatic switching upon detecting new plugged in device but I'd rather not do it, because I don't want it to affect my usb speakers. Though I might do it one day.
Another way to stop the interference of the faulty jack is trough
$hdajackretask 
which is part of alsa-tools-gui.
I tried this once, the effect was total loss of sound on my laptop. So I decided this might be a bit too brutal for my tast.
Also, note I'm not using pactl set-sink-port as in pactl set-sink-port 1 analog-output-speaker because for some reason I get an error when I do it. Maybe because I have more than one sound cards.
Also useful commands to check what sound cards you have and the names of the sinks (or sources) are:
#pactl list sinks 
#pactl list sources
#pactl list cards

Няма коментари:

Публикуване на коментар