Using Xrander to set up specific monitor resolution

I came from a world of black and white when it is about GNU/Linux. No GUI but CLI. Hence, I normally don't care about monitor resolution. But there's a switch. Xorg is mature to be used on daily basis, albeit I still left my system at init 3 (the GUI normally at init 4 or 5).

To set up correct monitor resolution in the past is quite experimental. This is not the case with modern Linux, where normally it detects the optimum monitor resolution automatically.

With System Setting, we can identify the right output for each monitor 

DVI to VGA converter
But, there's an example where autodetect failed to do what we want. In this case, I use a graphic card that does not have a physical VGA out, but a DVI and a Display Port.  Hence to connect to a monitor with VGA port (without a DVI port) or a HDMI port (I haven't seen any monitor with Display Port), an adapter i.e. DVI to VGA can solve the physical port connection.


But this is not without a consequence, the correct monitor resolution is not detected perfectly. In this case, we need to call cvt and xrander:


This line will register a new modeline for monitor resolution

cvt 1440 900 60

Then, we need to pass this info to xrander. Note here is DVI-0, where my monitor is connected.

xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
xrandr --addmode DVI-0 1440x900_60.00

To activate the setting, we can call xrander once more:

 xrandr --output DVI-0 --mode 1440x900_60.00


The setting may not be permanent, unless we create a simple bash script and call it each time when we start any GUI/desktop. Lets called this script gui.sh and saved in /usr/local/script/ for example and set the permission to 755 (rwxr-xr-x).

#to force resolution when autodetect failed giving you the correct ones.
#!/bin/sh

#1440 x 900
cvt 1440 900 60
xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
xrandr --addmode DVI-0 1440x900_60.00
#xrandr --output DVI-0 --mode 1440x900_60.00

#1680 x 1050
cvt 1680 1050 60
xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
xrandr --addmode DVI-0 1680x1050_60.00
#xrandr --output DVI-0 --mode 1680x1050_60.00


#1920 x 1080
cvt 1920 1080 60
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode DVI-0 1920x1080_60.00
xrandr --output DVI-0 --mode 1920x1080_60.00

I am using KDE Plasma 4 right now, then we can use autostart program to run the script when GUI is started.


Activating script during GUI startup with autostart 



Comments

Popular posts from this blog

Merakit Destilator Bioetanol Sederhana (1)

DHT11 incubator with I2C LCD (part 1)

LM35 Incubator with LCD 16x2 on Arduino