How Do I Save Xrandr Settings?

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
DasFox
Level 3
Level 3
Posts: 148
Joined: Thu Apr 05, 2007 4:04 am

How Do I Save Xrandr Settings?

Post by DasFox »

I'm running nouvuea with 2.6.36.3 I compiled into a .deb package and installed and after running these cmds for my rez setup;

cvt 1680 1050
sudo xrandr --newmode 1680x1050 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA-1 1680x1050

I can't get the settings to stay adding them anywhere I've tried.

These are all the steps I've tried below that didn't work...

/etc/gdm/Init/Default at this line;

xrandr --output VGA-1 --mode 1680x1050
/sbin/initctl -q emit login-session-start DISPLAY_MANAGER=gdm

I also placed it like this in /etc/gdm/Init/Default that didn't work either;

PATH="/usr/bin:$PATH"
OLD_IFS=$IFS

xrandr --newmode 1680x1050 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA-1 1650x1080_60.00
xrandr --output VGA-1 --mode 1650x1080


Then I placed these two cmds in .xinitrc, .Xdefault and .xprofile with no success;

xrandr --newmode 1680x1050 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA-1 1650x1080_60.00


Next I tried arandr and when I log out of X and try to load the file I saved it complains that it can't find the mode for 1680x1050.

Next I added them in the 'Preferences' 'Startup Applications', as;

/home/user/.config/misc/auto_start.sh, with these cmds below in auto_start.sh in it, this worked when I logged into Gnome but it killed my mouse from working;

xrandr --newmode 1680x1050 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA-1 1650x1080_60.00


Plus I tried adding this into rc.local as /home/user/.config/misc/auto_start.sh and still no luck.

No matter what I've tried nothing works, the only thing slightly close is this executable script which works if I run it by hand so I know this will work, but I can't seem to get it
to load at startup...

Does anyone know how I can get this xrandr settings to be saved and load at startup?


THANKS
cronfy

Re: How Do I Save Xrandr Settings?

Post by cronfy »

I had same issue with nouvuea and two monitors, one is connected via DVI -> VGA converter and it's modes are not detected correctly.

I found correct "--newmode" parameters by connecting that monitor directly to VGA port and executing

Code: Select all

xrandr --verbose
(see man xrandr for --newmode syntax and examples)

Then I added these lines to /etc/gdm3/Init/Default:

Code: Select all

xrandr --newmode "my1280" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +HSync +VSync
xrandr --addmode DVI-I-1 my1280
Right before last line:

Code: Select all

exit 0
After reboot I just set up two monitors and these setting are now kept across reboots.
danardf
Level 1
Level 1
Posts: 5
Joined: Wed Nov 07, 2012 2:33 am

Re: How Do I Save Xrandr Settings?

Post by danardf »

Hi.

I tried to apply this way, but unfortunatelly, it not works.
There is several ways on the web to trying to save this kind of stuff, but i can see that's not really easy and efficient.

I use a Samsung syncmaster 933HD.
All works fine after these cmd:
xrandr --newmode "1360x768" 84.72 1360 1424 1568 1776 768 769 772 795 -HSync +Vsync
xrandr --addmode VGA-0 "1360x768"
xrandr --output VGA-0 --mode 1360x768
But in your comments, i cannot see /etc/gdm3/ folder. So....

Also, i tried to add this file : .config/autostart/autostart.sh including xrandr -s 1360x768 -r 60, but no luck.

It's wierd to have a nice OS without be able to set resolution, and save easily our custom configuration.
I cannot count how many distro aren't able to customise any resolution during installation. It's always a battle.

If you could help me, it will be great. :D

Regards

Franck
cwsnyder

Re: How Do I Save Xrandr Settings?

Post by cwsnyder »

Any answer is very much going to depend on which login manager you are using. Putting things in /etc/gdm3/Init/Default only works if you are using the gdm3 login manager for a gtk desktop. If you are using, say lightdm (also gtk), kdm for qt based desktops, or xdm (which is for any desktop), the place to put the commands will vary. At least you can use xrandr. If you enter xrandr on a line by itself and the response begins the second line with default, xrandr often won't work, and I am still researching to find a method to fix this type of problem.

For Lightdm, you need to add the lines in /etc/lightdm/lightdm.conf

Code: Select all

[SeatDefaults]
#xserver-command=X
#xserver-layout=
#xserver-config=
xserver-allow-tcp=false
#xdmcp-manager=
#xdmcp-port=177
#xdmcp-key=
greeter-session=lightdm-greeter
greeter-hide-users=true
#greeter-allow-guest=true
#greeter-show-manual-login=false
#user-session=default
# for the login screen on lightdm
[newline]display-setup-script=/usr/share/videomode.sh[/newline]
# for the desktop session
[newline]session-setup-script=/usr/share/video2.sh[/newline]
#allow-guest=true
#guest-session=UNIMPLEMENTED
session-wrapper=/etc/X11/Xsession
#display-setup-script=
#greeter-setup-script=
#session-setup-script=
#session-cleanup-script=
#autologin-guest=false
#autologin-user=
#autologin-user-timeout=0
#autologin-session=UNIMPLEMENTED
#exit-on-failure=false
Where videomode.sh is a shell script which is executable with your xrandr --newmode / xrandr --addmode / and xrandr --output lines, but video2.sh is simply an executable shell script with the xrandr --output line. You then, when you get to your desktop need to use your Display menu setting to set the newly available mode for it to be (semi-)permanent. Reference http://askubuntu.com/questions/63681/ho ... -permanent

In Xdm for Debian based distributions, the config file is usually found in /usr/X11R6/lib/X11/xdm/xdm-config and I found a reference http://forums.debian.net/viewtopic.php?t=20201 stating that the proper place to put your commands is in /etc/X11/xdm/Xsetup

According to the Ubuntu Wiki at http://manpages.ubuntu.com/manpages/luc ... kdm.1.html, for kdm, the config file to put your xrandr lines in would be /etc/kde4/kdm/Xstartup (script to run as root before session starts) unless you need to have it run earlier to get a usable display for login.
danardf
Level 1
Level 1
Posts: 5
Joined: Wed Nov 07, 2012 2:33 am

Re: How Do I Save Xrandr Settings?

Post by danardf »

hmmm thanks for these explanations, :)

unfortunatelly, nothing right.

At first, i added some lines into : /etc/lightdm/lightdm.conf , like this:

Code: Select all

[SeatDefaults]
greeter-session=unity-greeter
user-session=cinnamon
display-setup-script=/usr/share/videomode.sh
session-setup-script=/usr/share/video2.sh
Next, i just created 2 files, like this:
/usr/share/videomode.sh

Code: Select all

xrandr --newmode "1360x768"  84.72  1360 1424 1568 1776  768 769 772 795  -HSync +Vsync
xrandr --addmode VGA-0 "1360x768"
/usr/share/video2.sh

Code: Select all

xrandr --output VGA-0 --mode 1360x768
Applying chmod a+x for both under root.

I restarted my LinuxMint station, but nothing changed. :?

thanks for your help :wink:
cwsnyder

Re: How Do I Save Xrandr Settings?

Post by cwsnyder »

Did you check in your Display settings to see if your new mode has been set in your display selections?

My resolution did not change on reboot, but when I checked in the Display settings, there was a selection for the higher resolution in the pull-down menu.
danardf
Level 1
Level 1
Posts: 5
Joined: Wed Nov 07, 2012 2:33 am

Re: How Do I Save Xrandr Settings?

Post by danardf »

Hi.
Did you check in your Display settings to see if your new mode has been set in your display selections?
Hmmm yes, before to change, i had some resolution up to 1024x768.
After change, my new resolution appears into the list.
My resolution did not change on reboot, but when I checked in the Display settings, there was a selection for the higher resolution in the pull-down menu.
Hmmm, my resolution stays on 1024x768 max.
So, my parameters aren't saved. :(

Thanks

Regards :wink:
cwsnyder

Re: How Do I Save Xrandr Settings?

Post by cwsnyder »

Do I understand you correctly that you have the selection of 1360x768 on your display list, but you can't make that selection? Or is it that when you make that selection your display goes bonkers?
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How Do I Save Xrandr Settings?

Post by AlbertP »

If you need any xrandr commands in terminal to get the correct resolution, then you can put those commands in the .xinitrc file in your home folder to have them executed every time you login.
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
danardf
Level 1
Level 1
Posts: 5
Joined: Wed Nov 07, 2012 2:33 am

Re: How Do I Save Xrandr Settings?

Post by danardf »

cwsnyder wrote:Do I understand you correctly that you have the selection of 1360x768 on your display list, but you can't make that selection?
No, When i'm loging, at fist i've this:
Image

Next, I launch my 2 scripts like this. (faster) :)
Image

Next, i can see my new resolution, like this:
Image

And finally, i've this list:
Image
cwsnyder wrote:Or is it that when you make that selection your display goes bonkers?
No, when i select my resolution, all works fine.
But, when i restart the station, i lose my new resolution (1360x768).

Regards
cwsnyder

Re: How Do I Save Xrandr Settings?

Post by cwsnyder »

I am using Lightdm with LMDE Xfce, and I put my scripts and pointers in the /etc/lightdm/lightdm.conf file and the results were exactly the same as when I did it with Lightdm in my Debian Wheezy installation. That is, I had to login the first time, select the default resolution which I wanted, and was available from both Menu >> Settings >> Display and Arandr without re-running my scripts, then reboot and my next login I had my default display resolution set where I wanted it.

The big problem I see is that you have to run your scripts again after you login.

I had a late thought. I had a problem with my gdm3 LMDE installation, the colors for my password were white on light-grey, so I fired up Synaptic and loaded Lightdm, since that was what my Debian Wheezy install used. The result was that my login screen was usable again. As I said, I added the scripts which I wrote because my monitor's EDID is not recognized and added the pointers in /etc/lightdm/lightdm.conf as I show above and everything worked.

You may want to consider changing your login manager from gdm3 to either lightdm or xdm and see if they work better.
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How Do I Save Xrandr Settings?

Post by AlbertP »

Have you already tried putting the two commands in the .xinitrc file in your home folder (create it if it doesn't exist) like I said?
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
User avatar
asobczak
Level 1
Level 1
Posts: 43
Joined: Sun Jun 10, 2012 5:32 pm
Location: Warsaw, Poland

Re: How Do I Save Xrandr Settings?

Post by asobczak »

Hi,
In my case it works this way:
I create a file 91_custom_xrandr and place it in directory /etc/X11/Xsession.d
Be carefull about names in this directory, since they have to follow the rules described in man Xsessions
file content:
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI1 1920x1080_60.00
Restart machine and voila!


PS I spend too much time on reading and trying, me dumb newbeeee, so tell me it works for you :evil:
System: Host: Kernel: 5.4.0-66-generic x86_64 bits: 64 compiler: gcc v: 7.5.0
Desktop: Cinnamon 4.4.8 wm: muffin dm: LightDM Distro: Linux Mint 19.3 Tricia
base: Ubuntu 18.04 bionic
danardf
Level 1
Level 1
Posts: 5
Joined: Wed Nov 07, 2012 2:33 am

Re: How Do I Save Xrandr Settings?

Post by danardf »

asobczak wrote:Hi,
In my case it works this way:
I create a file 91_custom_xrandr and place it in directory /etc/X11/Xsession.d
Be carefull about names in this directory, since they have to follow the rules described in man Xsessions
file content:
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI1 1920x1080_60.00
Restart machine and voila!


PS I spend too much time on reading and trying, me dumb newbeeee, so tell me it works for you :evil:
Yesss. thanks a lot.
Works fine now... :D

Have a nice day, and thanks again at all for your help. :wink:

Regards
User avatar
asobczak
Level 1
Level 1
Posts: 43
Joined: Sun Jun 10, 2012 5:32 pm
Location: Warsaw, Poland

Re: How Do I Save Xrandr Settings?

Post by asobczak »

I am glad it works for you.
Enjoy your Mint ;)
PS Mark thread Solved
System: Host: Kernel: 5.4.0-66-generic x86_64 bits: 64 compiler: gcc v: 7.5.0
Desktop: Cinnamon 4.4.8 wm: muffin dm: LightDM Distro: Linux Mint 19.3 Tricia
base: Ubuntu 18.04 bionic
gadien

Re: How Do I Save Xrandr Settings?

Post by gadien »

AlbertP wrote:If you need any xrandr commands in terminal to get the correct resolution, then you can put those commands in the .xinitrc file in your home folder to have them executed every time you login.
I have found a page that gives a detailed outline to what needs to be done for Linus Mint 13 (Maya):
http://community.linuxmint.com/tutorial/view/877
jojopumpkin

Re: How Do I Save Xrandr Settings?

Post by jojopumpkin »

asobczak wrote:Hi,
In my case it works this way:
I create a file 91_custom_xrandr and place it in directory /etc/X11/Xsession.d
Be carefull about names in this directory, since they have to follow the rules described in man Xsessions
file content:
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI1 1920x1080_60.00
Restart machine and voila!


PS I spend too much time on reading and trying, me dumb newbeeee, so tell me it works for you :evil:
This worked for me using Mint KDE (15). Thanks @asobczak
maxcel
Level 1
Level 1
Posts: 4
Joined: Mon Dec 05, 2011 9:59 am

Re: How Do I Save Xrandr Settings?

Post by maxcel »

asobczak wrote:Hi,
In my case it works this way:

I create a file 91_custom_xrandr and place it in directory /etc/X11/Xsession.d

Be carefull about names in this directory, since they have to follow the rules described in man Xsessions
file content:
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI1 1920x1080_60.00
Restart machine and voila!
[/quote]

This worked for me on Linux Mint 16 MATE. Thank you.
swastik

Re: How Do I Save Xrandr Settings?

Post by swastik »

asobczak wrote:Hi,
In my case it works this way:
I create a file 91_custom_xrandr and place it in directory /etc/X11/Xsession.d
Be carefull about names in this directory, since they have to follow the rules described in man Xsessions
file content:
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode HDMI1 1920x1080_60.00
Restart machine and voila!


PS I spend too much time on reading and trying, me dumb newbeeee, so tell me it works for you :evil:

Worked for me as well :D on a dual monitor/screen set-up that too

Many thanks.
amphibole

Re: How Do I Save Xrandr Settings?

Post by amphibole »

Hi! Congratulations to the OP. Glad it is working. I'm working on a similar problem tonight and found this thread. I'm using LMDE, btw.

On Nov 13 2012 was posted post 647413:
AlbertP wrote:Have you already tried putting the two commands in the .xinitrc file in your home folder (create it if it doesn't exist) like I said?
Specifically in answer to AlbertP and for the sake of others who read the thread: I don't believe that will ever work when you are using any X dm to login to your graphical session -- but please read what I am saying carefully, though, before just contradicting my statement.

My understanding is that modern X-using systems do not use .xinitrc for the majority of approaches to logins. Say, I could just stop here but instead I am going to go the extra mile to explain my meaning fully. I'd appreciate it if the reader would either ignore the posting entirely or else read it fully. Not something halfway in-between.

Oh, and if the suspicion is that I am wrong - that I am a 100% confused chucklehead, instead of the 33% or so that I actually am :P ...note that the OP mentioned that putting his xrandr ... commands in an ~/.xinitrc file did not provide the solution, as I'd expect he'd report.

If I was kinda a new user I might think that AlbertP had a point because the ~/.xinitrc file is mentioned all over the place in offline and online (WWW) documentation. Be careful. Much of what one finds is obsolete documentation that just needs to be archived somewhere but otherwise marked "BEWARE, THIS WILL ONLY CONFUSE YOU IN 2012." I've spent uncounted hours over the years checking this kind of documentation. I may not have everything right for every case, yet, but I have a pretty good overall idea.

What's wrong with ~/.xinitrc is that it is a relic from the days when people did not use modern X display managers and much of what those managers (together with the desktop session managers that you are switched to when you've authenticated / logged in) do, does replace what people in olden times used the ~/.xinitrc file for.

RTFM the manpage for xinit to see the authoritative description of how ~/.xinitrc is used.

If xinit is not being invoked ...and modern login defaults provided by refined GNU/Linux distros like LinuxMint do not involve invocation of xinit; instead a process owned by root is started (at the appropriate runlevel) that invokes an X11 Display Manager, a dm ...so then why would an ~/.xinitrc file have any effect?

I actually have an ~/.xinitrc because I actually run xinit on some occasions. I have specific reasons for doing so. My observation is therefore based on actual experience on several different current systems, is true across several distros, and my experience is that except when xinit is invoked from the linux console, ~/.xinitrc can either exist or not exist, can contain anything at all if it does exist, and will have no effect whatsoever.

Cheers!
Locked

Return to “Graphics Cards & Monitors”