how to set Phonon 'profile' via script?

I have a laptop i am trying to get to automatically switch between internal and external video & audio outputs automatically… when i connect my HDMI cable, then a script runs to reconfigure xrandr and the audio settings to the external display & speakers (via the HDMI cable).

the video side works ok; i’m using xrandr.

I haven’t yet been able to find any method to reconfigure the ‘Profile’ in Phonon (specifically Phonon > ‘Audio Hardware Setup’ tab > ‘profile’ drop-down box).
laptop internal speakers are ‘Analog Stereo Duplex’ profile, and HDMI speakers are ‘Digital Stereo (HDMI) Output’.

what options do i have to set this profile setting via terminal/script?
thanks for any help!

You have to find out where that configuration is stored and what in it should be changed. Knowing that a script to edit it wouldn’t be to difficult.

just to update the thread; it looks like either ‘pacmd’ or ‘pactl’ is the right tool for the job; i got it working with ‘pacmd’, but now i’ve changed laptop i don’t have much use for this now!