I used to edit the startup script for the GDM (/etc/gdm/Init/Default) to permanently change my display resolution.
How can I do this with LigthDM in Ubuntu Oneiric?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
I think you can add the display modes to
If you don't have a
xorg.conf, then you can use the following as a basis. You need to replace the entries with the names
Modes with the correct entries for your system. Depending on your hardware, you may need additional entries, for example if your system has more than one graphic chip.
Section "Monitor" Identifier "Monitor0" Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync EndSection Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" SubSection "Display" Modes "1280x1024_60.00" "1024x768_60.00" EndSubSection EndSection Section "Device" Identifier "Card0" Driver "nvidia" EndSection
If you don't know the name of the video driver that your system is using then you may get the name as follows (if you have an intel graphic chip, the driver name is just "intel"):
lshw -class display | grep "driver"
The modelines can be generated with
cvt <h-resolution> <v-resolution> [refresh]
/etc/lightdm/lightdm.conf to add the following options:
display-setup-script > calls your
mycustomloginvideo.sh before the login screen appears
session-setup-script > calls your
mycustomdesktopvideo.sh before the user desktop session starts
[SeatDefaults] greeter-session=unity-greeter user-session=ubuntu # for your login screen, e.g. LightDM (Ubuntu 11.10) or GDM (11.04 or earlier) display-setup-script=/usr/share/mycustomloginvideo.sh # for your desktop session session-setup-script=/usr/share/mycustomdesktopvideo.sh
You may have "
arandr" GUI tool generate the above sh script, picking parameters from your current session's X configuration.
Make sure that your shell script is executable:
chmod a+x /usr/share/mycustom*video.sh
and you can test that it works (i.e. that you don't have any typos or configuration errors in your
xrandr command) just by running it in a terminal:
If the login script doesn't work for any reason, your machine might not complete the boot process to the login screen. If the desktop script fails, you might not get a desktop after logging in. If you are setting an external monitor, these scripts will fail when you disconnect it, and X session will not start.
Some one posted another workaround, although I must say It didn't work for me. It could probably work for you. In my case it breaks unity and I can only move my mouse cursor around. The app indicator top panel looks empty, but after unplugging my LCD I was able to delete the added lines and everything went back to normal.
edit the file
Here is how the first part of that file looks now:
#!/bin/sh # # LightDM wrapper to run around X sessions. echo "Running X session wrapper" # Load profile for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do if [ -f "$file" ]; then echo "Loading profile from $file"; . "$file" fi done xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync xrandr --addmode CRT1 1368x768_60.00 xrandr --output CRT1 --mode 1368x768_60.00 # Load resources
Take note that the Xrandr settings should be changed to match yours.
I have been trying to solve a similar problem for a while now and found a solution that works for me so hopefully it will help...
I have an old aspire one AOA110 that I have broken the screen on too many times and after buying a new laptop decided that I would try to turn it into a HTPC but the external display I have is not recognised by X so I have had to 'tweak' it numerous times to get it working at the correct resolution.
Here is what I did:
After using this http://ubuntuforums.org/showthread.php?t=1112186 tutorial up to step 5 I was able to find a working and acceptable resolution in xrandr but this wasn't working on the LightDM login screen.
Don't follow the steps to make it persistent in the above how to it may work but I think this is the proper way to do it in 11.10. I found this post on the ArchWiki https://wiki.archlinux.org/index.php/Xorg which I adapted to my needs.
First create a file here:
Then add the appropriate X details for your display here is how mine looked:
Section "ServerLayout" Identifier "DualSreen" Screen 0 "Screen0" Screen 1 "Screen1" RightOf "Screen0" #Screen1 at the right of Screen0 #Option "Xinerama" "1" #To move windows between screens EndSection Section "Monitor" Identifier "LVDS1" Option "ignore" "true" EndSection Section "Monitor" Identifier "VGA1" Option "Enable" "true" Modeline "1440x900_60.00" 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync EndSection Section "Device" Identifier "Device0" Driver "intel" Screen 0 EndSection Section "Device" Identifier "Device1" Driver "intel" Screen 1 EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "VGA1" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 Modes "1440x900_60.00" EndSubSection EndSection Section "Screen" Identifier "Screen1" Device "Device1" Monitor "LVDS1" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 EndSubSection EndSection
The important bits to add are under the appropriate
Section "Monitor" include the appropriate
Modeline that you found while using
gtf 1440 900 60.00 and then under the corresponding
Section "Screen" including the correct
You'll notice that what I was trying to do was not only to set the VGA1 connection to a suitable resolution but also tell it not to use my LVDS1 output. Obviously you will need to tweak yours appropriately to match the right number of outputs and the right Device, Screen and Display sections for your setup.
Sorry for the epic post, I have been tweaking xorg.conf files for some time now with the Hannspree display I've been using and the old xorg.conf setups that I used pre 11.10 just don't work properly any more this is the only solution I've found that works.
I've had a similar problem with my laptop as above, and I wanted to add something to the conversation. If you don't care about the login resolution (I don't), but want the actual workspace to be the right resolution, you can add your monitor information to LightDM but not turn on full resolution until you login.
I just added the following script for my monitor in a file:
xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync xrandr --addmode VGA1 1440x900_60.00
then I call it in
Once I login I can setup my monitor in Displays and it works, even after I re-log (used to give me a big ugly error).
As an enhancement for Jon Roberts answer, let me specify that arandr does not include in its sh script generation all parameters working in the current session. Primary monitor (in case you are using a dual monitor configuration), refresh rate and gamma settings for each monitor are not included, for example. My session script looks like that:
#!/bin/sh xrandr --output LVDS --mode 1366x768 --pos 1600x432 --rotate normal --output HDMI-0 --off --output DVI-0 --off --output VGA-1 --mode 1600x1200 --rate 85 --pos 0x0 --rotate normal --primary xrandr --output VGA-1 --gamma 0.8:0.7:0.55
I manually added --rate and --primary options in the first line and then added manually a second line with the gamma correction because apparently xrandr gamma settings are lost whenever you switch a monitor to primary.
I do not know if this particular behavior with the gamma settings when making a monitor primary is intended or is a bug.
Moreover the session shell script is not called by lightdm but as a startup application, because it seems that lightdm calls the script before things are ready for xrandr and weird things happen.
I had the problem of wanting an extended display on my new LXDE box, (not a dual clone), found the correct command, but couldn't make it permanent.
xrandr --output VGA-0 --right-of DVI-0
The above methods all seemed too hard/not the right way to do it.
I eventually found this: http://www.sudo-juice.com/change-lxde-screen-resolution-ubuntu-lubuntu/
That worked a treat, but I used gedit instead:
gksu gedit /etc/xdg/lxsession/LXDE/autostart
Then added the line at the end with an @ symbol at the start:
@xrandr --output VGA-0 --right-of DVI-0
Hope that helps and thank you to sudo-juice.
PS Note the double
- in the xrandr command
-- (didn't show up too clearly on my screen).
Create a new document and name it e.g.
#!/bin/bash xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync xrandr --addmode VGA1 1600x900_60.00 xrandr --output VGA1 --mode 1600x900_60.00 unity --replace
and save it in your home folder (this sets the resolution to 1600x900)
Open Startup Applications (or run
gnome-session-properties) and click "ADD". Give a name and type in the command line:
Save it, and now the script will be ran now every you login, so you will need to logout first for it to take effect. Running the command (e.g.
bash /home/yourusername/yourscriptname.sh) in a terminal would also be a good idea to check whether the script works.
Based on responses upper, I have done some test and found a useful method that works to me, then I have created a simple script to automatize it with my automatic installs. But it will work to any other cases.
scriptinstallxrandrfixed.sh. Add these lines:
#Variables for lightdm script and xrandr script to set up fixed resolution for old displays: xrandrscript=/usr/local/bin/xrandrscript.sh lightdmstartscript=/usr/share/lightdm/lightdm.conf.d/60-xrandrscript.conf #Added old style configuration for lightdm: sudo ln -s /usr/share/lightdm/lightdm.conf.d /ec/lightdm/lightdm.conf.d #A fix to some old displays in high school at Fray Bentos, fix to 104x768 #Some useful information comes from: http://askubuntu.com/questions/63681/how-can-i-make-xrandr-customization-permanent sudo sh -c "echo '[SeatDefaults]' > $lightdmstartscript" # for your login screen, e.g. LightDM (Ubuntu 11.10) or GDM (11.04 or earlier) sudo sh -c "echo 'display-setup-script=$xrandrscript' >> $lightdmstartscript" # for your desktop session sudo sh -c "echo 'session-setup-script=$xrandrscript' >> $lightdmstartscript" sudo sh -c "echo 'xrandr --size 1024x768 --rate 60.0' > $xrandrscript" sudo chmod +x $xrandrscript
it will create the scripts and the files for lightdm display and session. Don't forgot to give it permission to execute
chmod +x scriptinstallxrandrfixed.sh
(you must be placed in same directory where you have the file.)
if not in same directory:
Modify it to feet your needs.