PDA

View Full Version : Screenresolution



jonblund
Nov 14th 2009, 01:19 PM
The optimal screen resolution for my monitor does not exist by default. To fix it I use the following 3 xrandr commands

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

Now I would like to save this commands so that the resolution become persistent after reboot. In Ubuntu, iv'e read, this could bee done in /etc/gdm/PreSession/default.
My question is: Where and how could I save this in Kubuntu 9.10?

lmilano
Nov 14th 2009, 09:35 PM
What happens if you open SYstem Settings -> Display after you run this commands? Do you see that resolution? Can you save it from there? Also, you can run krandrtray and perhaps save the resolution from there?

jonblund
Nov 15th 2009, 02:42 PM
I'm afraid not. What I need is probably some script, but I don't now how to wright it ore where to put it.

dibl
Nov 15th 2009, 02:58 PM
If you save this in your user's home folder with the filename ".kderc" then it should be read immediately after you log in:


#!/bin/bash
sleep 1 && # slight pause to make sure there's time to read it
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync"
sleep 1
xrandr --addmode VGA1 "1280x1024_60.00"
sleep 1
xrandr --output VGA1 "1280x1024_60.00"
#end


After you save it, you need to


chmod +x .kderc to make it executable.

I don't guarantee your commands -- I just copied them from your post. :)

jonblund
Nov 16th 2009, 07:07 PM
The 3 xrandr commands I use is, and they work:

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

Iv'e tried to add this to your script but the script isn't reed when i restart X.
The script is saved to ~/.kderc with permissions rwx and looks like this:

#!/bin/bash
sleep 1 && # slight pause to make sure there's time to read it
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync"
sleep 1
xrandr --addmode VGA1 "1280x1024_60.00"
sleep 1
xrandr --output VGA1 --mode "1280x1024_60.00"
#end

What could bee wrong?

dibl
Nov 16th 2009, 07:37 PM
The 3 xrandr commands I use is, and they work:

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

Iv'e tried to add this to your script but the script isn't reed when i restart X.
The script is saved to ~/.kderc with permissions rwx and looks like this:

#!/bin/bash
sleep 1 && # slight pause to make sure there's time to read it
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync"
sleep 1
xrandr --addmode VGA1 "1280x1024_60.00"
sleep 1
xrandr --output VGA1 --mode "1280x1024_60.00"
#end

What could bee wrong?



Ooops, I see a typo (that I made). There should not be a quote mark at the end of the first command (after +vsync).

But, that would not affect having the script read upon login. Probably (after fixing the typo) you merely need to run the script once.

Open the Konsole and enter


sh .kderc

In succeeding KDE sessions, it will "remember" what was running in the last session, and start it up again.

lmilano
Nov 16th 2009, 07:38 PM
Not sure, but you can also add a script to Autostart in System Settings, that _will_ work, though it may do it a bit late, so you'll see a bit of a flicker while loading the desktop.

jonblund
Nov 17th 2009, 02:48 PM
The 3 xrandr commands I use is, and they work:

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

Iv'e tried to add this to your script but the script isn't reed when i restart X.
The script is saved to ~/.kderc with permissions rwx and looks like this:

#!/bin/bash
sleep 1 && # slight pause to make sure there's time to read it
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync"
sleep 1
xrandr --addmode VGA1 "1280x1024_60.00"
sleep 1
xrandr --output VGA1 --mode "1280x1024_60.00"
#end

What could bee wrong?



Ooops, I see a typo (that I made). There should not be a quote mark at the end of the first command (after +vsync).

But, that would not affect having the script read upon login. Probably (after fixing the typo) you merely need to run the script once.

Open the Konsole and enter


sh .kderc

In succeeding KDE sessions, it will "remember" what was running in the last session, and start it up again.



The problem is that KDE won't remember. After sh .kderc the script works find, but as soon as I log out It's gone. Iv'e tried autostart, same thing.
I desided to try somthing radical and quite over my head, and It seems to work!
I copied the content from ~/.kderc to the /etc/kde4/kdm/Xsetup script


#! /bin/sh
# Xsetup - run as root before the login dialog appears

#xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &

# Kubuntu needs boot splash starting, KDM will kill it when it is running
if ! grep -q ^AutoLoginEnable=true /etc/kde4/kdm/kdmrc; then
ksplashx Default &
fi

sleep 1 && # slight pause to make sure there's time to read it
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
sleep 1
xrandr --addmode VGA1 "1280x1024_60.00"
sleep 1
xrandr --output VGA1 --mode "1280x1024_60.00"
#end

After reboot everything look ok. and the new mode is present in system settings -> display
But I feel unsure if it's ok. Would be nice to have some more experienced saying on this :-\

dibl
Nov 17th 2009, 03:13 PM
The problem is that KDE won't remember. After sh .kderc the script works find, but as soon as I log out It's gone. Iv'e tried autostart, same thing.



Assuming you are the only user on that computer, your method is fine. It is now a global script, for all users, but on a one-user system that is kind of moot point.

I had assumed that you had the System Settings > Advanced > Session Manager set to the default "Restore Previous Session". If so, and you (a) run the script in a Konsole window, and then (b) restart your X session (or reboot the computer), then the expected behavior is that KDE will resume your prior session and run the script again.

But, I could be wrong about one of those assumptions -- we all know about assumptions, right? ;)

jonblund
Nov 17th 2009, 05:42 PM
No problem with users i am the only one.
Session manager has default settings, but still it won't work. Anyway this solution is fine for me.
Thanks for all help!