Adding newmode with Xrandr - "800x480_60.00"

Approach 1: Using Startup Applications

You could make an executable script file and add it to the list of Startup Applications. Here is a screenshot how the result of next steps looks in my system.

1. Create a directory where the script file will be contained. For example this directory could be placed into your home directory and could be named .autorun-startup:

mkdir ~/.autorun-startup

2. Create the script file and make it executable:

  • Let's call this file custom-screen-resolution.sh:

    nano ~/.autorun-startup/custom-screen-resolution.sh
    

    In this example is used Nano text editor (where you can use ctrl+o to save the edits and ctrl+x to exit), but you can use your favorite text editor.

  • The content of the script custom-screen-resolution.sh should look as this:

    #!/bin/sh
    # To calculate the modeline use: cvt 800 640 60 
    # To view the available modes and the output names use: xrandr
    # Create new mode:
    xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync
    # Add the new mode to the list of modes of certain output:
    xrandr --addmode LVDS1 800x480_60.00
    # Set the new mode as current for the certain output: 
    xrandr --output LVDS1 --mode 800x480_60.00
    
  • Set executable permissions to the file custom-screen-resolution.sh (or use Nautilus):

    chmod +x ~/.autorun-startup/custom-screen-resolution.sh
    

3. Open the application Startup Applications, click on the Add button to add a new entry and fill the parameters values:

Name:     Custom Screen Resolution
Command:  /home/<user>/.autorun-startup/custom-screen-resolution.sh
Comment:  Add Custom Screen Resolution

Save the entry and Close Startup Applications.


Approach 2: Using XDG Utils

  • This approach allows you to execute the above commands during system startup system wide (for all users). For this purpose you must create .desktop file and place it into a appropriate place, to be more specific, according to the example into the directory /etc/xdg/autostart/. I found this approach here, but there are also available and other ways how to use XDG Utils tools package.

1. Create a directory where the .desktop file will be contained:

sudo mkdir -p /etc/xdg/autostart

2. Create the .desktop file and make it executable:

  • Let's call this file custom-screen-resolution.desktop:

    sudo nano /etc/xdg/autostart/custom-screen-resolution.desktop
    
  • The content of the file custom-screen-resolution.desktop should look as:

    [Desktop Entry]
    Name=Custom Screen Resolution
    Exec=sh -c 'xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync; xrandr --addmode LVDS1 800x480_60.00; xrandr --output LVDS1 --mode 800x480_60.00'
    Terminal=false
    Type=Application
    Categories=Application
    

    Make sure custom-screen-resolution.desktop has read permissions system wide.

  • Set executable permissions to the file custom-screen-resolution.desktop. In this case, this step is optional and you need it, if you want to test your file via 'double click'.

Note 1: The .desktop file could use the script created in the above approach. For this purpose change the Exec as follow (make sure custom-screen-resolution.sh has read permissions system wide):

Exec=/home/<user>/.autorun-startup/custom-screen-resolution.sh

Note 2: Create the .desktop file within the directory /home/<user>/.autorun-startup and then make a symbolic link to /etc/xdg/autostart:

sudo ln -s /home/<user>/.autorun-startup/custom-screen-resolution.desktop /etc/xdg/autostart/

Further reading

Add resolution:

  • How to set the monitor to its native resolution which is not listed in the resolutions list?
  • How can I make xrandr customization permanent?
  • Where is the X.org config file? How do I configure X there?
  • How to add a resolution in display settings?
  • How do you permanently add a resolution on a laptop with Ubuntu 14.04 for a secondary monitor connected with a VGA cable?

Startup commands:

  • start up command
  • How to run scripts on start up?
  • Differences how to run scripts at startup
  • how can i write a shell script that will run at startup and introduce a delay in the start of an application
  • Adding path to PATH environment variable using bash script in /etc/environment