0

This question already has an answer here:

For the past few days, I've been trying to match my second screen's resolution to my match my main screen.

Using the following code i got from this website, I was to get it done:

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

My problem, now, is when i reboot my computer, the second screen goes back to its old resolution. Then, i learned that i have to add these scripts to this file sudo gedit /etc/modules which i did but still didn't work.

screenshoot of adding the code to modules I'm new to ubuntu and i'm really liking it. I can get my second screen set.

TIA!

marked as duplicate by Jacob Vlijm, Community Sep 7 '15 at 10:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

/etc/modules file is for kernel moludes ( aka drivers). It says right at the top of the file. That's not the right place to put custom commands.

Step 1: Take those 3 commands, save in a set-screen.sh somewhere in your home directory. For example, mine would be in /home/serg/bin/set-screen.sh and that's how it would look like:

#!/bin/sh
sleep 15
xrandr --newmode "1368x768_60.00"   85.25  1368 1440 1576 1784  768 771 781 798 -hsync +vsync
xrandr --addmode DVI-I-1 1368x768_60.00
xrandr --output DVI-I-1 --mode  1368x768_60.00

Step 2: do in terminal chmod 755 set-screen.sh.

Step 3: Open the Startup Applications and add full path to your file as one of the startup commands.

Note: alternatively you could add /bin/bash -c "sleep 15 && /home/serg/bin/set-screen.sh" as command to Startup Applications, and remove sleep 15 entry from the script itself

Now every time you log in, those 3 commands will run automatically 15 seconds right after you log in. Note, that these commands won't run until you log in, so the log-in screen will be with the old resolution

  • Without a small break before the script runs, in many cases the script breaks (due to xrandr commands) or misses its target, especially when using external screens. – Jacob Vlijm Sep 7 '15 at 8:09
  • @JacobVlijm so . . .should I add sleep 3 to the beginning ? – Sergiy Kolodyazhnyy Sep 7 '15 at 8:15
  • I think 3 is too little, I would say somewhere between 15 and 50, depending on the system. or make the xrandr test smart somehow :) – Jacob Vlijm Sep 7 '15 at 8:36
  • ...Or add the sleep to the startup command: `/bin/bash -c "sleep 15 && /home/serg/bin/set-screen.sh" – Jacob Vlijm Sep 7 '15 at 8:41
  • @JacobVlijm Edited my answer to include the suggestions :) – Sergiy Kolodyazhnyy Sep 7 '15 at 8:44
0

Use the xorg.conf

It's the best way to set the resolution for your second monitor:

Login use xrandr to change everything, so that the second monitor has the right resolution and then open a terminal and enter:

sudo Xorg :1 -configure
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_bak
sudo cp /root/xorg.conf.new /etc/X11/xorg.conf

(Do not forget to always backup your config files, if the second command fails because the file /etc/X11/xorg.conf doesn't exists, ignore it.)

See here for more details.

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