xrandr on boot? [SOLVED]

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
jage

xrandr on boot? [SOLVED]

Post by jage »

I use

Code: Select all

xrandr --output VGA-0 --primary
to make my monitor primary over my laptop screen, but noticed it is not persistent on booting.

Is there somewhere to put this in a boot sequence, or somewhere to record this as a preference?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: xrandr on boot?

Post by xenopeek »

Sure, you need to make a script and have it run during the X server initialization. Taking your piece of code, the following is how you could do this. Open a terminal and run:

Code: Select all

mkdir ~/Scripts
gedit ~/Scripts/setoutput.sh
Put the following two lines in the script.

Code: Select all

#!/usr/bin/env sh
xrandr --output VGA-0 --primary
Then save & close the file and run the following commands to finish the setup:

Code: Select all

chmod +x ~/Scripts/setoutput.sh
sudo ln -s ~/Scripts/setoutput.sh /etc/X11/Xsession.d/45setoutput
Image
jage

Re: xrandr on boot?

Post by jage »

You know in Control Center under Personal there is a "Startup Applications" and typing the xrandx command as written there worked smashingly.

I appreciate the script advice, but I'm a GUI guy and if I can do something without terminal I'd rather (I know, heresy of the worst kind...)

Anyway, just mentioning it in case this turns up in someone's search.
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: xrandr on boot?

Post by xenopeek »

Okay, if that works use it :wink: The xrandr script is especially applicable to people needing to change resolution. If you do that from Startup Applications, sometimes the desktop doesn't handle this right and, in addition to one more mode set (flicker of screen), it happens that panel applets get aligned wrong on the panel if you do it through Startup Applications.
Image
jage

Re: xrandr on boot? [SOLVED]

Post by jage »

Well eventually I came around to needing to change the resolution and this really helped. I followed these instructions to get my resolution commands:
http://www.ubuntugeek.com/how-change-di ... randr.html

With the codicil that you reboot and don't touch the GUI monitor, but go directly into terminal.

Once the 3 commands are built, I used Vincent's instructions to implement them on boot. For myself I have dual monitors so I actually had six lines of code, plus the shell line from Vincent's example:

Code: Select all

#!/usr/bin/env sh
xrandr --newmode "1280x800_60.00" 83.50 1280 1352 1480 1680 800 803 809 831 -hsync +vsync
xrandr --addmode VGA-0 1280x800_60.00
xrandr --output VGA-0 --mode 1280x800_60.00

xrandr --newmode "800x500_60.00"   30.75  800 824 896 992  500 503 509 521 -hsync +vsync
xrandr --addmode LVDS 800x500_60.00
xrandr --output LVDS --mode 800x500_60.00
I left the primary output in startup applications and it still works. Be sure to follow the URL instructions and use cvt to build your resolution, and stay away from the GUI monitor (if you get an error after "just checking" in the GUI just reboot)

Now I need to go back and fix that 800x500... not quite the perfect resolution for my secondary monitor yet.
jvdurme

Re: xrandr on boot? [SOLVED]

Post by jvdurme »

Hi all,

I tried the script solution, but it didn't work for me.
I'm using MATE, have an ATI Radeon 3650 (notebook) and want to set screen resolution to 1440x900 with:

xrandr --output LVDS --mode 1440x900 --rate 50

Unfortunately, when I do all the steps from above, screen stays at 1920x1200.

The Startup Applications thingy worked surprisingly. I did have 5 warnings about panel applets in error. But doing 5 times "killall mate-panel" made the errors go away. Still haven't seen them again.

There was also a lightdm.conf option, but also didn't work for me:

http://www.sudo-juice.com/lightdm-resolution/

In which I changed display-setup script to session-setup script. See sample file at /usr/share/doc/lightdm/lightdm.conf
mitsos1os

Re: xrandr on boot? [SOLVED]

Post by mitsos1os »

Just replying to note that @xenopeek solution is the proper one, because the xrandr commands have to be run after display has been initialized.
Working OS is Mint 18.2 Cinnamon

Check also here for the problem reported: https://unix.stackexchange.com/question ... esolutions
al3xsh

Re: xrandr on boot? [SOLVED]

Post by al3xsh »

Hi all,

I have tried the steps in @xenopeek's solution - i.e. linking a script into Xsession.d containing:

Code: Select all

#!/usr/bin/env sh
xrandr --output DP-0 --primary
but after login when i run xrandr DP-0 is still not set as primary. I can run the script from the terminal - which does set DP-0 to primary - but it doesn't seem to get set on startup.

Any ideas?

Regards,

Alex
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: xrandr on boot? [SOLVED]

Post by xenopeek »

Hi Alex, I suggest making a new topic to ask for help with this. You're replying to a 9 year old topic so not all information here may be applicable to current software.
Image
Locked

Return to “MATE”