I have 5-inch a 800x480 tft connected to the LVDS connector on a Portwell WADE-8020 mini-ITX embedded system board. I would like to build a XMBC/Kodi box for streming my music from my freenas PC with the tft showing what is been played, I got as fare as this...

sudo xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync`enter code here


sudo xrandr --addmode LVDS1 800x480_60.00

now that I get the correct resolution, I now have a black band on the top of the screen.

sudo xrandr --output LVDS1 --set "scaling mode"  "Full aspect"

However this did not solve the issue, also I know I need to amend the /bin/sh file with this from googling so I don't need to keep doing this at every boot. But I don't know how to as I'm very new to Linux.

xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync
xrandr --addmode LVDS1 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:

    # 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'

    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):


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:

Startup commands:

  • This is perfect, thank you very much. I'll get back if I run into difficulty. – Block Mar 6 '17 at 20:05
  • Another possible solution - create ~/.layout.sh and put there the xrandr's statements. – pa4080 Jun 15 '17 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.