The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.

# flexible monitor setup

Hi,

i want to use a felexible monitor setup:

case "on the road") i use only the display on my laptop (LVDS1)

case office) is use HDMI1 as my default display and LVDS1 as secondary

Is there a way to configure this?

edit retag close merge delete

Sort by » oldest newest most voted

Can't edit the above answer so here's how to use --primary with xrandr:

--primary will set a display to be primary, which will not affect which workspaces are on it, but can change where your systray icons are displayed if you've configured i3 to that effect.

I execute my xrandr commands in this way:

exec --no-startup-id xrandr --output HDMI-0 --off --output DVI-I-1 --mode 1280x1024 --pos 0x0 --rotate normal --output DVI-I-0 --primary --mode 1920x1200 --pos 1280x0 --rotate normal --output DVI-I-3 --off --output DVI-I-2 --off


That is, I give it a complete specification of my screens. The easiest way to find out what this should look like is to set up your screens the way you want, then use arandr (a simple xrandr gui) to export the xrandr line (Layout->Save As). Note that arandr will not set --primary for you. Do this yourself, immediately after the display you want to make primary.

You said you wanted --primary to ensure workspace 1 goes on your primary monitor. This won't happen, but you're going to want to move your workspaces between monitors dynamically and this will let you achieve what you want:

# move current workspace between monitors
bindsym $mod+Control+h move workspace to output left bindsym$mod+Control+j move workspace to output down
bindsym $mod+Control+k move workspace to output up bindsym$mod+Control+l move workspace to output right


I also use these things to rename workspaces. I often do this to rename workspace 2 to 10, so that I can have workspaces on my second monitor go from 10 downwards.

# rename current workspace
bindsym $mod+Control+r exec i3-input -F 'rename workspace to "%s"' -P 'New name: '  If you give a workspace a name such as "5: ssh", you can still go to it only if you've changed your binds like this: # switch to workspace bindsym$mod+1 workspace number 1
bindsym $mod+2 workspace number 2 bindsym$mod+3 workspace number 3
bindsym $mod+4 workspace number 4 bindsym$mod+5 workspace number 5
bindsym $mod+6 workspace number 6 bindsym$mod+7 workspace number 7
bindsym $mod+8 workspace number 8 bindsym$mod+9 workspace number 9
bindsym $mod+0 workspace number 10  more You can define key bindings to summon some xrandrprocesses as explained in the user guide: http://i3wm.org/docs/userguide.html#m... For instance: bindsym$mod+m         exec xrandr --output HDMI1 --off
bindsym $mod+shift+m exec xrandr --output HDMI1 --auto --right-of LVDS1  Edit to add a better answer to the OP question You could try the --primary argument for xrandr. I did not succeed in making it work with i3. Maybe there is a recipe to make it work. Another solution is to fake a swap of primary monitor by reassigning the workspaces outputs in your config. 1) First assign the output for each monitor workspace 1 output$mainoutput
workspace 2 output $secondoutput  2) Then you define the variables: At home: set$mainoutput   xinerama-0
set $secondoutput xinerama-0  At work, edit the config file: set$mainoutput   xinerama-1
set $secondoutput xinerama-0  3) Reload your config It could be easily automated with a script which modify the config given a template and then call i3-msg restart. more ## Comments thanks, this looks like a pretty great solution (i'll use it right now :)), but my main problem is if i'm at the office to specify HDMI1 as my main display with Workspace 1 on it ( 2013-08-09 20:29:25 +0000 )edit I edited the answer with a possible solution to this. ( 2013-08-10 04:41:52 +0000 )edit love this :) i automated this now ( 2013-08-12 08:10:06 +0000 )edit Hmmm, is it possible to redefine the variable with i3-msg? I also have variable outputs based on the monitor model - HDMI1 or DP2, but they are both above LVDS1 and share otherwise similar characteristics. EDIT you should use "move workspace to output up/down/left/right" ( 2013-08-24 14:57:52 +0000 )edit Personally, I use a script to manage my multiple monitor screen configurations; this way I never have to worry about switching it, the script will just do the right thing when i3 starts. I have three configurations: one at home (small monitor to the right of my LVDS), work (larger monitor to the right of my LVDS), and one on the road (just LVDS). I always use the native resolution of the flat panel. Other configurations will work, but you will have to alter the script. #!/bin/bash for output in$(xrandr | grep '\Wconnected' | awk '{ print $1 }'); do if [[$output =~ ^LVDS.*$]]; then lvds=$output
fi
done
for output in $(xrandr | grep '\Wconnected' | awk '{ print$1 }'); do
if [[ ! $output =~ ^LVDS.*$ ]]; then
xrandr --output $lvds --auto --output$output --pos 0x0 --auto \
--right-of $lvds --primary fi done  I call this script "autoxrandr" and it's placed in my$HOME/bin directory. I then call it from ~/.i3/config via a line like

exec --no-startup-id autoxrandr


The script works like this: it discovers which XRandR output is named LVDS-something and then assumes that all other monitors are to the right of the LVDS. This works for me because I always place the larger monitors on the right, because due to problems with my vision, I see better out of my right eye. It also will assume that the monitor furthest to the right will be primary. Obviously this is very simplistic and probably won't work for some other monitor setups.

If you want to have more monitors, say, one on the right and one the left, etc., to know which monitor is which you can get at the monitor's EDID via 'xrandr --verbose'; this will uniquely identify each monitor. Then you could build some smarts in your script that places each monitor where you want it, sets up the resolution, determines which is primary, etc. I'll leave that as an exercise to the reader.

more