Ubuntu – Run a startup script with lightdm

lightdmstartup

I have a tablet PC and the graphics driver doesn't support xrandr, so in order to rotate the screen I run a script which changes the Xorg.conf file and then restarts lightdm. I also have a script which uses xsetwacom and xinput to change the rotation of the input devices so that the match the new orientation.

I've learned how to get the script to run when I login, but I'd like it to run before I login, so that I don't have to enable auto-login with lightdm. I do need it to run though, or the input (touch and pen) is rotated with respect to the screen, so that when I touch the screen the input is in a completely different area, making it really difficult to use the onscreen keyboard.

I've looked at other questions on this site. I've tried putting my script in /etc/Xsession.d but that didn't seem to work. I also tried putting it in /etc/rc.local but I think that is the wrong place, nothing seems to happen. I've also tried googling for lightm script hooks, and various other google terms.

Any suggestions?

Edit 1: After doing some research, it seems to me that it might not be that I want to run a script with lightdm, but rather with the lighdm greeter (in this case, I think the unity-greeter?). Are there any script-hooks for the unity-greeter?

Best Answer

You might want to try adding pre-start or post-start scripts to

/etc/init/lightdm.conf

(see http://upstart.ubuntu.com/getting-started.html for an introduction to upstart that parses this file)

Also /etc/lightdm.conf allows to specify scripts to be loaded. You have a detailed description of all (many) the options that can be used in the configuration file lightdm.conf at /usr/share/doc/lightdm/lightdm.conf.