Setting up Custom Screen Resolution on Linux (Permanently)
Tags: linux, screen, resolution
Published: 2022-03-25 23:17:15

Perhaps, you have searched how to setting custom screen resolution or just resolution on Linux before.

After a few process, you have set up screen resolution and saw it's not affected on next reboot.

Alright, how to setting up custom screen resolution on Linux? Permanently 🦾

---

## Step.1

Learn name of your destination screen

In terminal,

```shell
xrandr
```
You can see output like bellow.

```shell
$ xrandr
Screen 0: minimum 320 x 200, current 2880 x 900, maximum 16384 x 16384
eDP-1 connected primary 1280x720+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1366x768      59.99 +  39.94
   1280x720      60.00*   59.99    59.86    59.74
   1024x768      60.04    60.00
   960x720       60.00
   928x696       60.05
   896x672       60.01
   1024x576      59.95    59.96    59.90    59.82
   960x600       59.93    60.00
   960x540       59.96    59.99    59.63    59.82
   800x600       60.00    60.32    56.25
   840x525       60.01    59.88
   864x486       59.92    59.57
   700x525       59.98
   800x450       59.95    59.82
   640x512       60.02
   700x450       59.96    59.88
   640x480       60.00    59.94
   720x405       59.51    58.99
   684x384       59.88    59.85
   640x400       59.88    59.98
   640x360       59.86    59.83    59.84    59.32
   512x384       60.00
   512x288       60.00    59.92
   480x270       59.63    59.82
   400x300       60.32    56.34
   432x243       59.92    59.57
   320x240       60.05
   360x202       59.51    59.13
   320x180       59.84    59.32
HDMI-1 connected 1280+720+0 (normal left inverted right x axis y axis) 160mm x 90mm
   1920x1080     60.00 +  50.00    59.94
   1280x1024     60.02
   1280x720      60.00    59.94
   1024x768      60.00
   800x600       60.32
   720x480       60.00    59.94
   640x480       60.00    59.94
   720x400       70.08
```
My screen names are `eDP-1` and `HDMI-1`.

In this example, i am gonna add custom screen resolution to `HDMI-1` screen and set as permanently.

---

## Step.2

Generate resolution parameter.

In terminal,

```shell
cvt 1600 900 60
```

With `cvt` command, we can create resolution modeline data.
Let me show you output.

```shell
$ cvt 1600 900 60
# 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
Modeline "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
```

To using on `xrandr` command, we have to copy output after `Modeline` word.

Like this,

```shell
"1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
```

---

## Step.3

Now we can create new resolution mode.

In terminal,

```shell
$ xrandr --newmode <copied commands>
```

For example,

```shell
$ xrandr --newmode "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
```

---

## Step.4

Add resolution mode.

```shell
$ xrandr --addmode HDMI-1 "<width>x<height>_<Hz>"
```

Like this,

```shell
$ xrandr --addmode HDMI-1 "1600x900_60.00"
```

Almost done!

---

## Step.5

Set custom resolution.

```shell
$ xrandr --output HDMI-1 --mode "1600x900_60.00"
```
---
## Make permanent!

Add all `xrandr` mode commands to `Xsetup` file.

```shell
$ sudo nano /usr/share/sddm/scripts/Xsetup
```

Add bellow,

```shell
xrandr --newmode "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync

xrandr --addmode HDMI-1 "1600x900_60.00"
```

We are not add screen resolution command because system has stored resolution data of specific screen already.

Save file and see yourself!