Announcement

Collapse
No announcement yet.

[Workaround] Fixing Wrong Display Settings At Startup

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Workaround] Fixing Wrong Display Settings At Startup

    Well, recently I kind of found a workaround for the issue we, not just me, are having with a wrong display resolution at Kubuntu's startup. It's pretty simple, it's like clicking krandrtray in 9.10 with KDE 4.3.x, but Kubuntu runs a short script at startup instead.

    You open Kate or Kwrite and type these lines...

    Code:
    #!/bin/sh
    exec xrandr -s 1/1024x768 && xrandr -r 70
    What it means is...

    Execute xrandr (what handles screen resolution and refresh rate) size pos_1/width/height and xrandr refresh rate 70 (Hz).

    Code:
    #!/bin/sh
    exec xrandr -s size_position/widthxheight && xrandr -r rate
    How do you get the correct position value that you must insert before forward slash?

    Just type xrandr in Konsole and it will show you a table with all available resolutions and their respective acceptable refresh rates. The * marks the current refresh rate.

    The resolution sizes are set like this...

    Size 0 would be your monitor highest resolution, Size 1 would be the second highest resolution available and so on.

    OK, you saved the script and possibly named it something like display.sh.

    What's next?

    Go to System Settings > Advanced Tab > Autostart.

    There click on Add Script... and a new dialog window will appear on screen.

    Enter the path to your file... (Remember the file named display.sh? Guess what, that's what you need to find now.)

    If you clicked on OK, then a new script file will be listed there. Under Run On column select Pre-KDE startup from the drop-down menu.

    FINAL STEP

    Now you're ready to restart your PC and test this workaround.

    NOTES

    The login screen will use the same screen resolution that drives you mad... but the rest will work pretty fine IMHO.

    What will this small script do?

    It will automatically resize the screen resolution and set your preferred refresh rate at once, just after the screen changes from login to splash screen. Once you can see your desktop, everything should be fine, I mean, it shouldn't look so messy anymore.
    Multibooting: Kubuntu Noble 24.04
    Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
    Win XP, 7 & 10 sadly
    Using Linux since June, 2008

    #2
    Re: [Workaround] Fixing Wrong Display Settings At Startup

    Originally posted by kyonides
    Just type xrandr in Konsole and it will show you a table with all available resolutions and their respective acceptable refresh rates. The * marks the current refresh rate.
    If the screen resolution you want is not displayed by xrandr - it's still possible to get it.

    I'm not advocating the method below as a permanent fix if you're having video problems, but I do have something to add.

    NOTE * IF YOU FORCE YOUR MONITOR TO A REFRESH RATE IT CANNOT DISPLAY, YOU COULD BREAK IT.

    Get the native resolution and refresh rate from your manufacturer. Do not trust forums or software.

    All these commands are done in a console:

    First find out what port x is using

    xrandr -q

    will show all output ports and resolutions. You will normally be using VGA or VGA1 and the output will look like

    Code:
    Screen 0: minimum 320 x 200, current 2624 x 1200, maximum 2624 x 2048
    VGA connected 1600x1200+1024+0 (normal left inverted right) 367mm x 275mm
      1600x1200   60.0*+
      1920x1440@60  60.0 
      1600x1200@60  60.0 
      640x480@60   60.0 
      640x480    60.0 
    LVDS connected 1024x768+0+0 (normal left inverted righ  1024x768    60.0*+  50.0 
      800x600    60.3 
      640x480    60.0   59.9 t) 304mm x 228mm
      1024x768    60.0*+  50.0 
      800x600    60.3 
      640x480    60.0   59.9 
    TV disconnected (normal left inverted right)
    Once you have determined the correct output (VGA, DVI1, LVDS, TV, TDMS-1, whatever) then you need a new modeline. To get it, enter the resolution and refresh rate you want into cvt or gtf like this (example assumes 1280x1024 at 60hz)

    cvt 1280 1024 60

    the output will be like

    Code:
    # 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz
    Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
    This is your new modeline. You must then add the modeline to xrandr and attach it to the correct output. First - put the new mode in xrandr

    xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync


    Notice the modeline is duplicated exactly except for the word "Modeline". Then attach it to your VGA (or whichever) port

    xrandr --addmode VGA 1280x1024_60.00

    Notice NO QUOTES this time.

    Then set it and display it

    xrandr --output VGA --mode 1280x1024_60.00

    This will take effect immediately.

    Once you have done all this and are happy with the results, you can follow the above post - but remember -> the newmode, addmode and output commands will have to be repeated in your script.

    A more "correct" method would be to now create a new /etc/X11/xorg.conf file with the correct mode settings. Then kdm will display properly too.

    Please Read Me

    Comment


      #3
      Re: [Workaround] Fixing Wrong Display Settings At Startup

      NOTE * IF YOU FORCE YOUR MONITOR TO A REFRESH RATE IT CANNOT DISPLAY, YOU COULD BREAK IT.
      I know why you would say that but I still feel insulted. What xrandr tells you is what your graphic card supports, so it's not that easy to break your monitor as you think.

      You know why I posted this? Because "a more "correct" method" like the one you suggested did NOT work for some of us. Just take a look at different subfora and you'll see what I mean. For some reason xorg.conf is NOT working as expected, KDE in some way or the other ignores it as well as krandrrc. I really want to know why, but it got to be a bug. Otherwise I wouldn't understand why krandrtray thinks that I selected 75 or 60 as my preferred refresh rate instead of 70, the one I actually picked up. Even if I correct this in krandrrc, it stills shows me a screen with a higher resolution than the one I setup originally while still working on Kubuntu.

      And no, my workaround did NOT fry my monitor.
      Multibooting: Kubuntu Noble 24.04
      Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
      Win XP, 7 & 10 sadly
      Using Linux since June, 2008

      Comment


        #4
        Re: [Workaround] Fixing Wrong Display Settings At Startup

        Originally posted by kyonides
        NOTE * IF YOU FORCE YOUR MONITOR TO A REFRESH RATE IT CANNOT DISPLAY, YOU COULD BREAK IT.
        I know why you would say that but I still feel insulted. What xrandr tells you is what your graphic card supports, so it's not that easy to break your monitor as you think.
        I wasn't trying to say YOUR advice was bad - MY added posting was about ADDING modes that xrandr doesn't automatically detect and therefore it is MUCH more likely that an inexperienced user would do something bad. I agree "it's not that easy to break your monitor," but it is possible. In my case, I learned to use this method because I use an expensive plasma TV as a monitor for my multi-media computer that doesn't correctly report it's available modes via EDID and setting it at an out-of-range refresh rate might indeed do some damage. I am simply trying to add more information to an already informative and useful thread.

        Additionally, if I give some hi-tech advice and someone uses it and breaks something, I could be at fault - the quoted line was to protect me from that and to warn others this is not to be lightly played with.

        The rest of your retort isn't worth commenting on. If you feel insulted - maybe you're too sensitive. Really - it isn't all about you.

        Please Read Me

        Comment


          #5
          Re: [Workaround] Fixing Wrong Display Settings At Startup

          I reviewed this post again to make sure I hadn't been picking on you. I can't see why you would be so "insulted" by my adding more function to your self-labeled "workaround" but I did decide to respond to a little more of your second post:

          Originally posted by kyonides
          You know why I posted this? Because "a more "correct" method" like the one you suggested did NOT work for some of us. Just take a look at different subfora and you'll see what I mean. For some reason xorg.conf is NOT working as expected, KDE in some way or the other ignores it as well as krandrrc. I really want to know why, but it got to be a bug. Otherwise I wouldn't understand why krandrtray thinks that I selected 75 or 60 as my preferred refresh rate instead of 70, the one I actually picked up. Even if I correct this in krandrrc, it stills shows me a screen with a higher resolution than the one I setup originally while still working on Kubuntu.
          Where exactly the problem lies is undetermined by this post so far.

          You didn't say what video/monitor combination you're are using, but I do know there is a known bug with nvidia drivers and xorg not correctly reporting the refresh rate to KDE. This issue occurs when DynamicTwinview is loaded by xorg and is easily fixed.

          As you stated yourself - your workaround leaves the login screen at the incorrect resolution. I did find several posts regarding incorrect resolutions, but I believe the "correct" way to handle this issue is to correctly configure xorg, thus resolving the resolution issue throughout ones system rather than just in one instance.

          Having said that - your workaround may be useful to some so I took the time to expand on it. One of the systems I am working on has a similar problem and I've been battling it in my spare time for weeks and I may put your script idea to the test.

          Please Read Me

          Comment


            #6
            Re: [Workaround] Fixing Wrong Display Settings At Startup

            NOTE * IF YOU FORCE YOUR MONITOR TO A REFRESH RATE IT CANNOT DISPLAY, YOU COULD BREAK IT.

            Get the native resolution and refresh rate from your manufacturer. Do not trust forums or software.
            Kyonides, the warning is appropriate, considering the topic, and was not, IMO, a personal attack. The advice about using manufacturing data and not forums and software is also excellent advice.

            All of us are smart, some in one area and some in another. We all need each other to maximize the benefits of this forum. So, allow me to recommend some advice I received some time ago when I felt I was being attacked: turn the other cheek. It works wonders!
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Re: [Workaround] Fixing Wrong Display Settings At Startup

              Back to the OP -

              There is a bash script already on your system that launches (or is supposed to) when you start X - /etc/kde4/kdm/Xsetup.

              Code:
              #! /bin/sh
              # Xsetup - run as root before the login dialog appears
              
              #xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &
              Putting your xrandr commands in here should give you the same results as the script in the first post.

              Please Read Me

              Comment


                #8
                Re: [Workaround] Fixing Wrong Display Settings At Startup

                At the end of the code there's and & I think, why is it there? Or is something missing?
                Multibooting: Kubuntu Noble 24.04
                Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
                Win XP, 7 & 10 sadly
                Using Linux since June, 2008

                Comment


                  #9
                  Re: [Workaround] Fixing Wrong Display Settings At Startup

                  & means that the command will run in background and the caller will not wait for it to finish before continuing.

                  Comment


                    #10
                    Re: [Workaround] Fixing Wrong Display Settings At Startup

                    That code I posted is just the default contents of the file on a Karmic install. I believe if you put kyonides script contents into the /etc/kde4/kdm/Xsetup they will be executed at the appropriate time.

                    Please Read Me

                    Comment


                      #11
                      Re: [Workaround] Fixing Wrong Display Settings At Startup

                      Well, I inserted my code there but it never setup the refresh rate correctly... but the resolution was the right one...
                      Multibooting: Kubuntu Noble 24.04
                      Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
                      Win XP, 7 & 10 sadly
                      Using Linux since June, 2008

                      Comment


                        #12
                        Re: [Workaround] Fixing Wrong Display Settings At Startup

                        That's odd. Something must be happening in between Xsetup and the actual desktop loading. Maybe I'll get onto my media computer (the one with a similar issue) and try it myself.

                        What video card and driver are you using And also out of curiosity, do you have an xorg.conf file at all? If yes - post the contents or attach it. I'd like to figure out what's going on.

                        Please Read Me

                        Comment


                          #13
                          Re: [Workaround] Fixing Wrong Display Settings At Startup

                          Well, I (90%) solved this issue, but the Xsetup script always forget about setting the refresh rate to 70 MHz as I expected. To solve it I pasted a xorg.conf in /etc/X11/ and put a refresh rate range between 60 and 70 (60 - 70) which are allowed by my graphics card and now it sets up my screen resolution and refresh rate correctly... but the login box is kind of drawn too close to the lower right corner... but the desktop looks fine and there's no need to put anything back into it's rightful place.
                          Multibooting: Kubuntu Noble 24.04
                          Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
                          Win XP, 7 & 10 sadly
                          Using Linux since June, 2008

                          Comment

                          Working...
                          X