How to force screen/s resolution in Ubuntu and make it permanent


 
 

Sometimes our ubuntu drivers don't work so well as we espect with our screens, most of the time we get a low resolution in our screens and cannot change it via GUI, fortunately using xrandr we can easily configure our screens to force them to a better resolution.

First of all, get the screens active in your pc:

$ xrandr 
Screen 0: minimum 320 x 200, current 3520 x 1200, maximum 32767 x 32767
LVDS1 connected 1600x900+1920+0 (normal left inverted right x axis y axis) 310mm x 174mm
   1600x900       60.0*+
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
HDMI1 disconnected (normal left inverted right x axis y axis)
VGA-0 connected primary 1280x1024+0+0 (normal left inverted right x axis y axis) 518mm x 324mm
   1280x1024      75.0     60.0  
   1152x864       75.0  
   1280x720       60.0     50.0     59.9  
   1024x768       75.1     60.0  
   800x600        75.0     60.3  
   720x576        50.0  
   720x480        60.0     59.9  
   640x480        75.0     60.0     59.9  
   720x400        70.1  
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

Let's create a new resolution using cvt

$ cvt 1368 768 60
1368x768 60.89 Hz (CVT 1.44M9) hsync: 70.55 kHz; pclk: 151.25 MHz
Modeline "1368x768_60.00"  85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync

Now we Add a new mode to the existing list (newmode is the name and remaining portion is )

$ sudo xrandr --newmode "1368x768_60.00"  85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync

What we do now it's to find the current display/s

$ xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/"
VGA-0

Add new display mode where is the output from the previous command

$ sudo xrandr --addmode VGA-0 1368x768_60.00

This will add the new resolution to your existing list of supported resolutions. You can then choose the right option from the "display settings" or following command

$ xrandr --output VGA-0 --mode "1368x768_60.00"

To make this change permanent,

$ cat> ~/.xprofile
sudo xrandr --newmode "1368x768_60.00"  85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
sudo xrandr --addmode VGA-0 1368x768_60.00
xrandr --output VGA-0 --mode "1368x768_60.00"

edit the file /usr/sbin/lightdm-sessionand add the xrandr configuration after the # Load profile section

Here is how the part of that file looks now:

#!/bin/sh
#
# LightDM wrapper to run around X sessions.


echo "Running X session wrapper"


# Load profile
for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
  if [ -f  "$file" ]; then
     echo "Loading profile from $file";
     . "$file"
  fi
done


xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
xrandr --addmode VGA-0 1368x768_60.00
xrandr --output VGA-0 --mode 1368x768_60.00


# Load resources


Take note that the Xrandr settings should be changed to match yours, so before check your screen/s with the initial command

 
 

tags: ubuntu screen resolution xrandr linux


We use our own cookies and third-party cookies to improve our services, show products based on your preferences, analyse the browsing habits of our users, and enable interaction with social networks. Continuing to browse our sites implies full acceptance of their use. You can change your cookie setting or get more information here: Cookies policy .