Set Screen Resolution in i3 with Xrandr


Live in i3, live in the terminal. No GUI for changing display properties. So, here's a CLI command to set a new screen resolution.

tl;dr

In xrandr lingo, a "mode" is approximately a "resolution" and an "output" is a "monitor".

xrandr # list available outputs and modes
cvt 3840 2160 60 # calculate mode line (for 3840x2160)
xrandr --newmode  # create new mode
xrandr --addmode  3840x2160_60.00 # associate mode with output
xrandr --output  --mode 3840x2160_60.00 # set output use mode

Use the man pages for extra help.

Discover screen capability

First, discover what displays and resolutions are available to you. Do that with:

xrandr

You'll get an output something like:

eDP-1 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   2560x1440    165.00*+  40.00 +
   1920x1440     85.00    75.00    60.00
   ...

Look for preconnected displays that are already ready to display things. Connecting displays can be a chore in itself, depending on circumstances. We won't cover that here.

Note the output name -- in this case eDP-1.

Unlisted resolutions

You may not have the desired mode listed for the output. But the output may support another mode. xrandr may tell you about the min or max resolutions.

Once you know your resolution, xorg wants you to specify it as a new mode. To get to that step, you need a modeline to feed to it. To get the modeline, use the cvt command. Feed it cvt .

For, cvt 3840 2160 60 on this monitor, I get:

# 3840x2160 59.98 Hz (CVT 8.29M9) hsync: 134.18 kHz; pclk: 712.75 MHz
Modeline "3840x2160_60.00"  712.75  3840 4160 4576 5312  2160 2163 2168 2237 -hsync +vsync

The text after "Modeline" is what you need for the next step.

To get that mode added to the output, it requires a two-stepper:

xrandr --newmode "3840x2160_60.00"  712.75  3840 4160 4576 5312  2160 2163 2168 2237 -hsync +vsync
xrandr --addmode eDP-1 3840x2160_60.00

This creates a new mode called "3840x2160_60.00" and associates it with eDP-1 output.

Set the resolution

Now that you have the mode set up and associated with the output, use xrandr to set the output to use that mode.

xrandr --output eDP-1 --mode 3840x2160_60.00

If it works, your monitor will immediately switch into the requested resolution. Say hello to tiny 4k terminal text.

Persist resolution choice

Now if you want to persist this change so you don't have to type the xrandr commands in the next time you reboot, then add the --newmode, --addmode and --output commands to ~/.xprofile.