How to auto run xrandr to rotate screen 90 degree when ubuntu desktop start-up

Dear Technical Support,

The following is my steps:
1. Create service file on /etc/systemd/system/xxx-app.service

Description=Gui Application

2. Create script file /opt/nvidia/l4t-usb-device-mode/
set -e
export DISPLAY=:0
mkdir -p /tmp/test1
/usr/bin/xrandr -o left
mkdir -p /tmp/test2
cd - # Out of /sys/kernel/config/usb_gadget
exit 0

3. Run the command “systemctl enable xxx-app.service” to config the service on start-up

Reboot, I don’t see the effect rotate screen. it seem failed to run command “/usr/bin/xrandr -o left”
I can see folder /tmp/test1 been created but /tmp/test2 not create.
Under manual open terminal, The command “xrandr -o left” is working correctly.
Would you please give me any advice to resolve the issues?


I remembered there was one method for this. You could use the GUI -> system setting ->display setting to rotate the monitor first.

After that, it will generate a config file under home directory. You could copy the format of that config file to other device so that it would rotate by default in each boot.