This page permanently redirects to gemini://gmi.bacardi55.io/blog/2023/07/10/new-laptop-part6-managing-multi-screens-with-i3wm-and-autorandr/.
Posted on 2023-07-10
For some time now, I've been using 3 external screens connected to my laptop. With my previous laptop, 3 screens was the maximum so I couldn't use the laptop screen with the 3 external ones. A problem I don't have anymore since [I switched to the framework laptop] :). But even though I could use 4 screens, I don't. I prefer to "limit" myself to the 3 external screens. The screens are mounted on a 3 arms monitor stand similar to [this one (/!\ Amazon link, sorry)] and I don't like looking down on the 4th screen.
But it is still a laptop, which means I move it a lot. Sometime just as a laptop, sometime connected to a transportable screen or a TV or others. Also sometime I go into "ultra focus mode" where I enable only the middle screen and disable the 3 others (where usually I have chat(s) and/or emails). So I need a way to switch quickly between these modes.
For that, I use xrandr to setup my screens as I want, autorandr to automate the switch to the mode corresponding to the number of screens plugged in and i3wm scripts with rofi for manual change.
To configure the screens position, I use xrandr GUI. Pretty rough UI but does the job. Once I'm happy, I save the configuration with autorandr with the following command:
autorandr --save
Do that each time you have a setup you want to reuse quickly. When a screen is (un)plugged, autorandr will try to find the saved profile that match the current situation. If any, config is applied automatically (Wether you want it or not :p). It is that easy :).
While it is usually good enough, it doesn't work for when I want to go into "focus mode" (only 1 screen enabled even though 3 screens are plugged in). I don't want to unplug screens, just disable them until I change my mind. To do so, I created a small script that I launch via a keybind (super + shift + space). This script will open a rofi pop-up asking me for one of the mode. They are hardcoded for now, I should improve that in the future to automatically find for the different existing profile in the autorandr config… But that's for another time! Then the selected value is used within a i3-msg command to start the right autorandr command. The content of the script is as follow (or always [up to date version on sourcehut]):
#!/usr/bin/env bash --- title: "Define an associative array:" date: 2023-07-10 --- typeset -A mode --- title: "And its content:" date: 2023-07-10 --- mode=( [Home]="autorandr --load home" [Laptop]="autorandr --load laptop" [Focus]="autorandr --load focus1screen" [Presentation]="autorandr --load dualprez" [4screens]="autorandr --load 4screens" [Cancel]="" ) mode_nrows=${#mode[@]} selected="$(printf '%s\n' "${!mode[@]}" | sort | rofi -dmenu -p "Monitor setup" -i -lines 2)" i3-msg -q "exec --no-startup-id ${mode[${selected}]}"
And voilà, pressing the super + shift + space keybind, I have the below pop-up asking me for the mode to use:
=> I switched to the framework laptop | this one (/!\ Amazon link, sorry) | up to date version on sourcehut
=> /gemlog/
=> Send me a gemini mention | send me an email! This content has been proxied by September (3851b).Proxy Information
text/gemini; lang=en