Saturday, February 3, 2018

How do I run script on startup to fix screen orientation issue?




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.



Thanks.



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#.*#normal#' "$HOME/.config/monitors.xml" >/dev/null 2>&1



  • Replace normal with your desired orientation.

  • This command will substitute something with desired value 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.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...