I'm using manjaro-linux-i3 with polybar and I'm currently working on my multiple monitor setup. I have a TV which I normally use with the amplifier it is connected to. In addition I have my desk with a triple monitor setup which I normally use with my headphones for audio output. One of my screens is in portrait orientation which always messes up my login screen.
I'm able to change my audio ouput and my active monitor as I wish. But I want it to be more efficient. At the moment I'm using arandr to change my monitor and pavucontrol to change my audio output when needed.
I want that my login manager(lightdm) is always displayed correctly on my monitors(even on the portrait one). It would be nice if anybody could give me way how to combine changing monitors and the audio output in one blow. So that I don't have to this every time manually.
I have similar setup and I got everything working what you might want if I understood you corretely.
If you setup everything right, then your loginmanager should always be displayed on the monitor which is active at boot and you can switch your monitors&sink with a simple keybind.
First, you can add a script to lightdm to config your monitors so that everything is displayed correctely. But be aware that a broken script can leed to the effect that your loginmanager won't be loaded correctly (blackscrren).
in /etc/lightdm/lightdm.conf
you can define a script at #greeter-setup-script=
. Simply uncomment the line and add the path to your script.
An easy way to config your monitors the way you want is to use arandr. Simply config your monitor the ways you want and save the setup. You will be saving an usual xrandr command, which can be used in your script.
Here is my script. It is very basic and actually only checks if a monitor of my desk is active. If so, it initialises the monitors of my desk. If not, it initialises my tv. It also sets the audio output I use with those monitors.
To get a list of all active monitors use this command:
xrandr --listactivemonitors | awk '!/Monitors/ {print $4}'
To get a list off all sinks(audio output) use this command:
pacmd list-sinks | grep -e 'name:' -e 'index:' | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}'
Now you can change my commands (sink and monitor names) with the onces you need. You can execute the script in the terminal so get feedback of the choosen sink and monitor (for testing). Don't forget to make your script executable else it won't work.
I got a similar script to manually change between my tv and my desk (mirroring scrrens, duplicate, tv-only, ect)
It too changes the sink according to the selected monitors. As you are using polybar too, you might notice that I relaunch polybar with sh /home/lluks/.config/polybar/launch.sh
This is the script.
It ensures that my applets are displayed on the main monitor as poylbar can only display them on one monitor. This is archieved by using a 2 diffrent bars for poylbar.
For this script to work, you need dmenu and rofi. If I remember corretely, you also need Font Awesome for the icons.