17

I found somewhere in a forum the solve to a problem where the only resolutions available were 800x600 and 1024x768. I managed to get 1440x900, which works very well. Every time I reboot, it disappears. I am forced to retype the commands, so how can I save this? I'm assuming it is a simple command, but I am the largest of noobs when it comes to Ubuntu. The commands are:

  • xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
  • xrandr --addmode VGA1 1440x900_60.00
  • xrandr --output VGA1 --mode 1440x900_60.00
21

You have several choices but perhaps the easiest is to place your command exactly as you have given above in your $HOME/.xprofile file. From here it will be executed every time you login.

By default this file does not exist in Ubuntu and so may need to be created manually and then be made executable. The following commands will do this:

touch $HOME/.xprofile
chmod +x $HOME/.xprofile

Note the 2 small shortcomings of this method:

  1. .xprofile is accessed occurs fairly late in the startup process so you may see some initial screen resolution resizing
  2. This is a 'per user' setting and may need to be repeated for other users on your system

If you wish to delve deeper there are a few other choices available in the reference link below, but this is still the safest and easiest.

References:

| improve this answer | |
  • 1
    You have saved me so much time! Thank you, it works flawlessly! – Jacob J. Apr 5 '16 at 23:26
  • 2
    +1 This works nicely when logging in. Does anyone know how to fix it so I can actually see the login screen? – James Bradbury Aug 6 '18 at 14:50
16

The accepted answer applies the same configuration regardless of the status of connected displays. This didn't work for me, as I'm connected to different displays at work and at home. autorandr allows automatic xrandr configurations for different display setup. To use autorandr,

  1. Install with sudo apt install autorandr (tested on Ubuntu 18.04)
  2. Configure your monitor to your liking with xrandr
  3. Store your configuration with autorandr --save work (I'm storing my work config, choose a name that suits you)
  4. Resume the config with autorandr --change work to choose config, or just autorandr --change to have it infer your config from your connected monitors.

XDG autostart .desktop is also provided, and installed into /etc/xdg/autostart/autorandr.desktop by default. That means when you reconnect your work monitor, the work setup will be reloaded.

| improve this answer | |
2

The following simple configuration works for me, and when connected, my monitor automatically uses the correct resolution without any manual intervention.

sudo nano /etc/X11/xorg.conf

Note that this file may or may not already exist. Add the following:

Section "Monitor"
    Identifier "VGA1"
    Modeline   "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
EndSection    

Then reboot. If all goes well, then things should just work.

Background

I have a UX32VD laptop, and I wanted to have 4K over HDMI, even though there is no 3840x2160 option in the display settings.

My first task was to compute the modeline. Skip this step if you already know the modeline. (The modeline below may work for you.) I downloaded umc-0.2.tar.gz, extracted, and ran ./configure and make. To get the 25Hz Reverse Blanking Timing mode, I ran

umc-0.2/src/umc 3840 2160 25 --rbt

which outputs

    # 3840x2160x24.99 @ 54.625kHz
    Modeline "3840x2160x24.99"  218.500000  3840 3888 3920 4000  2160 2163 2167 2186  +HSync -VSync

Next I wanted to test this modeline. Running xrandr with no arguments, I saw that my HDMI device is named HDMI-1. I tested this mode by running commands analogous to Jacob's:

xrandr --newmode "3840x2160x24.99"  218.500000  3840 3888 3920 4000  2160 2163 2167 2186  +HSync -VSync
xrandr --addmode HDMI-1 "3840x2160x24.99"
xrandr --output HDMI-1 --mode "3840x2160x24.99" --preferred

Finally, to make the resolution permanent, I created /etc/X11/xorg.conf with the following contents:

Section "Monitor"
    Identifier "HDMI-1"
    Modeline   "3840x2160x24.99"  218.500000  3840 3888 3920 4000  2160 2163 2167 2186  +HSync -VSync
EndSection  

To test, restart the computer.

I should note that I am running nvidia-driver-390 on Ubuntu 18.04. Hopefully my technique generalizes well to other configurations. (Please let me know in the comments.)

| improve this answer | |
0

You can use the autostart directory to apply the right xrandr settings when starting up the graphical environment:

  1. Determine the xrandr command to use. For example when using the GUI tool arandr, you can do "Layout → Save As …" and then open that file to find the command.

  2. Use your desktop environment's configuration GUI to set up a custom autostart application with the xrandr command you found.

  3. Restart the computer to see the effect.

Alternatively to no. 2, you can do the exact same thing manually by creating a file ~/.config/autostart/xrandr-settings.desktop with the following content:

[Desktop Entry]
Type=Application
Version=1.0
Name=custom xrandr settings

# Replace with your own xrandr command:
Exec=xrandr --output LVDS-1 --pos 0x1024 --output VGA-1 --pos 0x0

Advantages, Details

I like this mechanism better than putting the command into $HOME/.xprofile as proposed in another answer. Because pretty surely the autostart directory will already contain entries provided or even required by the desktop environment, and this way I have all autostarted stuff incl. xrandr together in one place rather than having to figure out where something is autostarted if I ever want to change it.

The autostart directory is a FreeDesktop mechanism, so it should work in all major Linux desktop environments. From another answer (by villapx, licenced under CC-BY-SA 4.0):

The autostart directory is a part of the freedesktop.org/XDG Desktop Application Autostart Specification. Per that spec, a compliant desktop environment will search $XDG_CONFIG_HOME/autostart for any .desktop files and execute them on startup.

| improve this answer | |
0

Finally, after endlessly mucking around with xrandr and .xprofile and .xinitrc and /etc/xorg.conf, none of which worked for the greeter or would stick permanently, this is what worked:

Note the path is /usr/share/X11/xorg.conf.d/

Create a new file 10-my-monitor.conf there...

# sudo vi /usr/share/X11/xorg.conf.d/10-my-monitor.conf

And include the screen and monitor fragment of the xorg.conf.

Section "Monitor"
    Identifier  "LGThing"
    Modeline    "FourK30" 338.75  3840 4080 4488 5136  2160 2163 2168 2200 -hsync +vsync
    Option      "PreferredMode" "FourK30"
EndSection

Section "Screen"
    Identifier  "MyScreen"
    Monitor     "LGThing"
    DefaultDepth    24
    SubSection  "Display"
        Modes     "FourK30"
    EndSubSection
EndSection

I got the modeline from cvt.

| improve this answer | |

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.