Monday, June 6, 2011

Forcing a Screen Resolution in Fedora 15

I love linux.  I really do.  It's gotten better and better over the years with functionality, hardware detection, and user friendliness.  Where it still falls flat on its face however is when something doesn't work as expected, most times it requires digging into some obscure configuration file somewhere to put in a custom fix, and Google becomes your best friend.  That and the fact that it's getting all GUI and bloated like Windows.  Ugh. ;-P

Anyway, I just wiped out my Fedora 12 linux server in order to install Fedora 15, primarily due to lack of updates for 12, but also just to play with the new GNOME 3.0, GNOME Shell, and service management tools.  I usually have it running headless, but every once in a while, do need to do something GUI based.  That's when I plug it into the nearest monitor, my trusty 4-year old 47" Vizio GV47LF.  This TV is fully 1080p (1920x1080@60Hz), but for whatever reason, it gives out incorrect EDID information over its VGA connection.  Its claimed maximum resolution is only 1360x768@60Hz.  This issue affected any operating system that I've had plugged in via VGA in the past, requiring custom fixes like using SwitchResX in Mac OS X (10.5.8) or PowerStrip in Windows.

With Fedora, I never bothered searching for a fix, as I usually connected to it via ssh and just didn't care enough to bother with it.  Had some time over the weekend to poke around and put together a pretty decent fix that should work well for most of you in a situation like mine where your monitor just isn't playing ball nicely.

First, after logging in, open up a Terminal and type:

xrandr -q

This should return to you a list of resolutions and refresh rates that the system is being told by your monitor that it supports.  In addition, you'll find the name of the output that the system has assigned to your monitor at the start of the second line.  The man pages refer to it as VGA, for example, but for my particular situation it was VGA1.

Next, you'll need to put together a modeline for your particular situation to outline the true display capabilities that your monitor supports.  In my case it was:

"1920x1080" 148.350 1920 2008 2056 2200 1080 1084 1089 1125 +hsync +vsync

Finally, what you'll need to do is go and edit "/etc/gdm/Init/Default".  This is a startup script that gets referenced whenever X is starting or restarting.  You may want to make a backup copy of the file first, you know, just in case.  You will need root access to modify this file.  Anyway, you'll want to add in three (3) lines right before the "exit 0" at the end of the file:

xrandr --newmode [your modeline here]
xrandr --addmode [your output here] 
xrandr --output [your output here] --mode [your new mode here]

In my example:

xrandr --newmode "1920x1080" 148.350 1920 2008 2056 2200 1080 1084 1089 1125 +hsync +vsync
xrandr --addmode VGA1 1920x1080
xrandr --output VGA1 --mode 1920x1080

Once those edits are added, save the file, and logout.  You should find that the changes take place immediately, and your login screen is now running at the full resolution that your monitor actually supported all along!

Hope that helps!

8 comments:

  1. Stuart,
    I just installed Fedora15 and followed your instructions to set screen resolution. It didn't work. Is there anything else that you did apart from this to make it work?

    -Srini

    ReplyDelete
  2. Hi Srini,

    I didn't need to do anything else. What kind of behavior are you seeing? You do need to make sure that you are using a modeline that is specific to your display's capabilities. There are various places to look, for example the AVS Forum (http://www.avsforum.com/) or the MythTV Modeline Database (http://www.mythtv.org/wiki/Modeline_Database). You could also try to generate one with The XFree86 Modeline Generator (http://xtiming.sourceforge.net/cgi-bin/xtiming.pl). And before adding anything into /etc/gdm/Init/Default, you should test out your modeline at the command-line with xrandr to make sure it works as expected.

    -Stuart

    ReplyDelete
  3. Top post - really monitor handling in Fedora is a real pain in the neck . . . come on Fedora folk - it works out of the box in Windows 7 . . . you want to compete ? . . .

    ReplyDelete
  4. do you know how to do this in KDE? there is no "/etc/gdm/" folder on my Spin kde fedora15. I need the exact same resolution...

    ReplyDelete
  5. Hi theone,

    I just booted up a live USB stick of the KDE spin, and tested this out. It looks like all of the exact same commands should work, and you will simply need to place the three commands at the bottom of the /etc/kde/kdm/Xsetup file.

    Hope that helps!
    -Stuart

    ReplyDelete
  6. Thanks a lot. But I think this one is even nicer:
    http://blog.bodhizazen.net/linux/use-xrandr-to-set-a-screen-resolution/

    ReplyDelete
  7. The pain I was going through trying to find a way to sort this before I landed on your blog was immense! There's very little out there on this subject for Fedora, and you're little blog post explains everything clear as day. Really appreciate the time you've taken to post this little gem. Bookmarked.

    Mike

    ReplyDelete
  8. Thanks! Works great.

    If you use the modeline generator, you might have to remove the "@HZ" from the modeline it creates, wouldn't work for me until it was removed.

    Virtualbox has the output as "VBOX0" on my system.

    ReplyDelete