Easy solution for your port problem: your TV has an audio-only output port called either SPDIF or Optical Out that should look like the top right port in this image:
This solves all your problems. Whatever HDMI input is being used by your TV automatically outputs its audio through this port. Buy an optical cable and make sure the soundbar you are buying has Optical In (vast majority have it - just double check).
Then just use your TV as normal, switch HDMI as much as you please. Audio will always follow through your soundbar. Done.