Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1903  / 2 Years ago, fri, october 28, 2022, 2:57:31

I've be looking for a way to run a script on startup but all old threads I've found on the subject seem to be before systemd came in and none of the answers I've found seem to work anymore. I'm new to Linux operating systems and I'm not sure where to look for instructions on how to do this under systemd.

For a bit of back story I recently replaced Windows on a little tablet/laptop with Ubuntu and I've found that on start up the screen orientation is the wrong way around, meaning every time I log in I have to enter xrandr -o right into the terminal, which is a bit annoying to do every time.

Additionally, if anyone has any resources for beginners entering Linux, I'd love to see them! I'm currently on a university degree and the programming side of things is all done on Ubuntu so it would be great to become more adept at using the system.


More From » scripts


I have the same issue within Ubuntu 16.04. Apparently it is a bug, something saves wrong value of the display orientation into the file ~/.config/monitors.xml. So if you execute xrandr -o right on startup the orientation value will be override when you login and the file monitors.xml is readied.

To fix this for a certain user, just add the following Cron job - crontab -e:

@reboot sed -i 's#<rotation>.*</rotation>#<rotation>normal</rotation>#' "$HOME/.config/monitors.xml" >/dev/null 2>&1

  • Replace normal with your desired orientation.

  • This command will substitute <rotation>something</rotation> with <rotation>desired value</rotation> within the file ~/.config/monitors.xml.

Unfortunately this workaround will fix the problem only when you start or reboot the system. When you log-out and log-in the problem may appear again. To fix this you can add your xrandr command in the Startup Applications.

[#8060] Friday, October 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 430
Total Questions: 105
Total Answers: 106

Location: Suriname
Member since Sun, Jun 13, 2021
3 Years ago