I will send special commands (example: Shift+Button Up) from the arduino via I2C to the raspberry.
Then i use a script on the raspberry to change volume with the linux mixer.
My solution has the following advantages:
- Stereo sound on the headphones
- Correct mixing of Stereo to Mono for the loudspeaker
- You can add a MOSFET between headphone jack switch and amplifier power in, so you dont have to power the amplifier, if you use headphones
- You don't need a pot, you can add resistors instead, so the headphone output can have the same loudness as the speaker
BUT also has its disadvantages:
- Changing of headphone volume needs the linux mixer
- You need an arduino leonardo or switches for vol+ and vol- connected to the raspberry
- More software needed
A perfect solution would be to use a linear amplifier, then you can connect L- and R- together (no BTL one, like the PAM8403).