Xrandr command in startup script has no effect, but script does run and command work from terminal

I cannot seem to get an xrandr command to rotate my monitor at startup.

The script:

cat /etc/X11/Xsession.d/999_test                                                                                                     
xrandr --output DVI-D-3 --off --output HDMI-3 --off --output VGA-1 --mode 1920x1080 --pos 0x0 --rotate left --output DVI-D-2-1 --off --output DP-2-1 --off --output DP-2-2 --off --output HDMI-2-1 --off --output DP-2-3 --off --output DisplayPort-1-3 --off --output DisplayPort-1-4 --off --output DisplayPort-1-5 --off --output HDMI-A-1-1 --off --output DVI-D-1-1 --off

xclock &

and the script itself is working, because if I add xclock & to the end of the script, I start my session with xclock lauched, but my screen not rotated (until I run the command from the terminal)

After logging in, if I run

 sh /etc/X11/Xsession.d/999_test

It works exactly as expected, rotating my monitor and opening xclock.

I don't see any errors related to xrandr or my script name in ~/.xsession-errors. Is that where I would expect to find them? I am using Lubuntu 20.04

Edit: As I had been using LXDE before, which has less advanced monitor management, I thought I needed to run this. Even though I do not need to, I'd still like to figure out why this didn't work. I thought that by naming it starting with 999 my script would be executed last and thus not be overridden by anything else.


I suggest that you use the 'autostart' feature of LXQt.

  • From the Main Menu
    • select Settings
      • select LXQt Configuration Center
  • select Session Settings
    • select Autostart
      • scroll down to and high-light 'LXQT Autostart'
  • click the Add button and add the action that you want.

This way you will create a desktop file in the directory

~/.config/autostart

When testing, I created screenmode.desktop. You can see it and the result, after logging out and logging in again in this screenshot:

enter image description here

Good luck with your longer and more advanced command line :-)