PINE64
Switching between Speakers and Headphones - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+---- Forum: UBPorts on PinePhone (https://forum.pine64.org/forumdisplay.php?fid=125)
+---- Thread: Switching between Speakers and Headphones (/showthread.php?tid=10744)



Switching between Speakers and Headphones - DrewTechs - 07-20-2020

I have written a couple of simple scripts that can switch the speakers and headphones and thought I share it. Pretty straightforward though, but maybe it can be updated to be written in one script and can detect whether the auxiliary port is connected to an auxiliary cable or not.

headphones.sh
Code:
#!/bin/sh
amixer -c 0 set 'Headphone' unmute
amixer -c 0 set 'Line Out' mute

speakers.sh
Code:
#!/bin/sh
amixer -c 0 set 'Headphone' mute
amixer -c 0 set 'Line Out' unmute



RE: Switching between Speakers and Headphones - Athansor - 07-21-2020

Dude, you have totally made my day! Thank you!


RE: Switching between Speakers and Headphones - natasha - 07-21-2020

nice! rate up!


RE: Switching between Speakers and Headphones - DrewTechs - 07-28-2020

I updated the script so that instead of having two separate scripts you can have just one.

audioswap.sh
Code:
#!/bin/sh
case "$1" in
    -h|--headphones|headphones|aux)
        echo "Disabling Speakers..."
        amixer -c 0 set 'Line Out'  mute
        echo "Enabling Headphones..."
        amixer -c 0 set 'Headphone' unmute
        echo "Done."
        ;;
    -s|--speakers|speakers)
        echo "Disabling Headphones..."
        amixer -c 0 set 'Headphone' mute
        echo "Enabling Speakers..."
        amixer -c 0 set 'Line Out'  unmute
        echo "Done."
        ;;
    -?|*)
        echo "Usage:"
        echo "\tSpeakers: -h | --headphones | headphones | aux"
        echo "\tHeadphones: -s | --speakers | speakers"
        echo "\tHelp: -? | *"
        ;;
esac



RE: Switching between Speakers and Headphones - natasha - 07-29-2020

Is this something is going to be integrated in the different OS?


RE: Switching between Speakers and Headphones - wibble - 07-29-2020

(07-29-2020, 12:23 PM)natasha Wrote: Is this something is going to be integrated in the different OS?
In Mobian you just use the dropdown in Settings -> Sound to pick the output device. I think it was similar in PmOS when I last tried it, but that was a while back.


RE: Switching between Speakers and Headphones - Athansor - 08-01-2020

Absolutely fantastic!


RE: Switching between Speakers and Headphones - Athansor - 08-06-2020

So, @DrewTechs , is there any way to slap a button on that script and put it on the desktop (or main screen or whatever it is on the phone)? Sadly, I don't program, but it seems to me that small addition would make the OS's inability to recognize the headphones pretty negligible.

Except for when you're on the phone. ofono doesn't use alsa, I guess?


RE: Switching between Speakers and Headphones - Peter Gamma - 09-05-2020

According to this site:

https://gitlab.com/ubports/community-ports/pinephone

earphone does not work on UBports. I m confused. What is working as far as audio is concerned on your UBports Pinephone?


RE: Switching between Speakers and Headphones - DrewTechs - 09-05-2020

(09-05-2020, 12:52 PM)Peter Gamma Wrote: According to this site:

https://gitlab.com/ubports/community-ports/pinephone

earphone does not work on UBports. I m confused. What is working as far as audio is concerned on your UBports Pinephone?

That's strange because I know the speakers and auxiliary ports both work but if you plug in headphones it doesn't automatically change the sound source to the auxiliary port.