I've switched on using i3 on my Linux laptop. I'm usually using only the laptop's internal monitor (display eDP1
), but when I'm at work I tend to connect a secondary monitor to my computer's HDMI port (display HDMI2
). So far, I've made this work fine by adding these commands to my i3 config file:
# use workspaces on different monitors
workspace "1: P1" output eDP1
workspace "2: P2" output eDP1
workspace "3: P3" output eDP1
workspace "4: P4" output eDP1
workspace "5: P5" output eDP1
workspace "6: S1" output HDMI2
workspace "7: S2" output HDMI2
workspace "8: S3" output HDMI2
workspace "9: S4" output HDMI2
workspace "10: S5" output HDMI2
# add HDMI monitor when connected
exec --no-startup-id xrandr --output HDMI2 --right-of eDP1
bindsym $mod+m exec --no-startup-id xrandr --output HDMI2 --auto --right-of eDP1
In other words, when I connect my HDMI display I just press Mod+M to get i3 to detect it, place it right of my primary display, and delegate 5 named workspaces (6-10) to it.
Here's the problem: At home, I have another monitor that I can connect with VGA (display DP2
). I can run the xrandr
command above to place this display to the right of my primary display as well, but I can't get the workspaces to be assigned to this display by default, unless I replace the rules I already have for my HDMI monitor. I would like both these workspaces to work the same no matter which monitor I use, so this is not an option.
TL;DR Is there a way to assign workspaces to two different displays, depending on which display is connected (assuming they never will be connected at the same time)?