Set custom screen resolution at Debian like

Published: 2017-09-03, Updated: 2018-03-01

If your resolution is wrong when your start the OS follow this article

Create a resolution fix script

The first step is to create a resolution fix script (set the right screen resolution, position, etc.) you can use ArandR to do it

 $ sudo apt-get install arandr

if your prefered resolution is not in the resolution list you must to create it manually

#!/bin/sh

# change the monitor settings 
RESOLUTION='1360 768 60' # 60 is the hertz value
MONITOR='DVI-1'

# you propably don't want to touch here
NEW_MODE_CMD=$(cvt $RESOLUTION | grep -oP 'Modeline\K.*')
NEW_MODE_NAME=$(echo $NEW_MODE_CMD | grep -oE '[0-9]{3,4}x[0-9]{3,4}')

xrandr --newmode $NEW_MODE_NAME `echo $NEW_MODE_CMD | awk '{$1 = ""; print $0}'`
xrandr --addmode $MONITOR $NEW_MODE_NAME

your can use the command xrandr --query | grep "\sconnected" to list all connected monitor codes

Open arandr, select the new resolution and test it, when all is configured and working you only have to click in layout -> save as and save the script in some temporary place. This script is a reference (many times the final) script to be used to setup your screen. Now we just need to create a new configuration file that will run with system start up and configure our screen settings

Most times it will create a new file

$ sudo touch /etc/X11/Xsession.d/45custom_xrandr-settings && \
  sudo chmod +x /etc/X11/Xsession.d/45custom_xrandr-settings

If your have to create a custom resolution, add the used script at this file, then also add the arandr content file, the file will look something like that

#!/bin/sh

# change the monitor settings 
RESOLUTION='1360 768 60' # 60 is the hertz value
MONITOR='DVI-1'

# you propably don't want to touch here
NEW_MODE_CMD=$(cvt $RESOLUTION | grep -oP 'Modeline\K.*')
NEW_MODE_NAME=$(echo $NEW_MODE_CMD | grep -oE '[0-9]{3,4}x[0-9]{3,4}')

xrandr --newmode $NEW_MODE_NAME `echo $NEW_MODE_CMD | awk '{$1 = ""; print $0}'`
xrandr --addmode $MONITOR $NEW_MODE_NAME

# arandr script content (as you can see I have two monitors one must to have custom resolution the other don't)
xrandr --output DisplayPort-0 --off --output DVI-1 --mode 1360x768 --pos 0x0 --rotate normal --output DVI-0 --off --output HDMI-0 --primary --mode 1920x1080 --pos 1360x0 --rotate normal

How to test it

Using arandr break all your settings then run this file manually and check if the screen will be configured well. If you get some error like that

X Error of failed request:  BadName (named color or font does not exist)

Just means that you are trying to create a mode that already exists, anyway when machine restart all mode will be deleted and the script will work with no warnings.

Obs: The resolution will get fixed just after you login in your account. That's all I hope it help you, this problem occour when you have a offboard GPU or a unknow monitor.


Saving data to two JDBC tables granting atomicity in Apache Spark ActiveMQ (Artemis) Vs RabbitMQ, what's the best?

Comments