How to make xrandr settings stick?

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Red Squirrel
Level 4
Level 4
Posts: 281
Joined: Sat Jan 31, 2015 11:42 pm

How to make xrandr settings stick?

Post by Red Squirrel »

I'm pulling my hair over this, I am experimenting with multi monitor, starting with 2 but eventually want to try 3 (can't find much resources on getting this to work, but will just bite the bullet and buy a video card with 3 proper outputs and try it). I want the centre one to be primary, not the most left one, which is the default.

I found that this command can set the primary:

Code: Select all

xrandr --output HDMI2 --primary
Problem is, anything command line like that does not stick. I tried everything, such as putting it in /etc/rc/local (which does not even seem to execute at all) and various X related scripts, and nothing works. How do I get this setting to stick? I also want it to be for all users. I only have 1 user account but if I setup another I don't want to have to do it all over again.

Thanks in advance.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Red Squirrel
Level 4
Level 4
Posts: 281
Joined: Sat Jan 31, 2015 11:42 pm

Re: How to make xrandr settings stick?

Post by Red Squirrel »

Anyone? There has to be a way to make a script run at startup in Mint? I'll settle for a user level script but I'm really hoping I can make this apply globally.
User avatar
roblm
Level 15
Level 15
Posts: 5939
Joined: Sun Feb 24, 2013 2:41 pm

Re: How to make xrandr settings stick?

Post by roblm »

To make the xrandr command persist after a restart, add it to /etc/mdm/Init/Default
Use this command in the Terminal to open the file:

Code: Select all

gksudo pluma /etc/mdm/Init/Default
That command is for MATE. If using Cinnamon or Xfce, change pluma to gedit.

Add the line at the bottom, just above the last line that says "exit 0".
Kendoori
Level 5
Level 5
Posts: 748
Joined: Thu Jul 09, 2009 12:51 pm
Location: Sanibel, FL USA

Re: How to make xrandr settings stick?

Post by Kendoori »

I use this script at startup: https://github.com/wertarbyte/autorandr

I also use some xrandr commands that has as shortcut for when I want to switch modes on the fly... like:
xrandr --output VIRTUAL1 --off --output DP3 --off --output DP2 --mode 2560x1600 --pos 0x0 --rotate normal --output DP1 --off --output HDMI3 --off --output HDMI2 --off --output HDMI1 --off --output LVDS1 --off --output VGA1 --off

I developed these "profiles" using:
http://www.ubuntugeek.com/arandr-a-simp ... randr.html
User avatar
I2k4
Level 5
Level 5
Posts: 784
Joined: Thu Feb 02, 2012 8:33 pm

Re: How to make xrandr settings stick?

Post by I2k4 »

I create an ".xprofile" file in Home and paste in three lines, as shown here:

http://ubuntuforums.org/showthread.php? ... ost8732038

Note that .xprofile starts with a dot and has no filetype suffix, and must be made executable in file properties. Works perfectly in Cinnamon and XFCE - resolution changes to your settings during the boot process.

Of course you need your own proper settings for the script. I get those with the command

cvt 1900 1200

The result provides the "Modeline" input for the three lines - you can see it finds 1904 instead of standard 1900 on my Samsung screen:

# 1904x1200 59.93 Hz (CVT) hsync: 74.61 kHz; pclk: 191.00 MHz
Modeline "1904x1200_60.00" 191.00 1904 2032 2232 2560 1200 1203 1213 1245 -hsync +vsync

Good luck.
TRUST BUT VERIFY any advice from anybody, including me. Mint/Ubuntu user since 10.04 LTS. LM20 64 bit XFCE (Dell 1520). Dual boot LM20 XFCE / Win7 (Lenovo desktop and Acer netbook). Testing LM21.1 Cinnamon and XFCE Live for new Lenovo desktop.
Locked

Return to “MATE”