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)?
Best Answer
You can't assign multiple outputs to single workspace, see: https://github.com/i3/i3/issues/555
So the only way is to change i3 config dynamically. You could assign to hotkey script that will be doing 2 things: changing monitor outputs with
xrandr
and moving workspaces withi3-msg
:With above script you will move 6-10 workspaces to DP2 and end up staying on workspace 10.
Update 2019: Multiple outputs assignment was implemented starting from v4.16, see https://i3wm.org/docs/userguide.html#workspace_screen. Now you could use them like that:
The first available output will then be used.