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?


3 Answers 3


I would like to add that display-setup-script=/path/to/some/script goes into the [Seat:*] ([SeatDefaults] in older versions) section of /etc/lightdm/lightdm.conf.

I use the script to setup the correct resolution and screen orientation for the greeter. This looks like:

xrandr --output DVI-0  --mode 1920x1200 --rotate left --primary
xrandr --output HDMI-0 --mode 1920x1080
  • 2
    Thank you, also on Debian it is in the wrong [Lightdm] section.
    – Alex
    Aug 24, 2013 at 11:30

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


(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.

  • Thanks for the suggestion, but this doesn't seem to be working either. I'm not 100% sure about how lightdm works, but it's my understanding that the lightdm process does not end when you login, but that it restarts the x server when logging in / logging out. Adding a pre-start script to lightdm get's my script to run before lightdm starts, but I think ligthdm starts x after this, so the settings I change via xinput/xsetwacom are not preserved by the time the login screen is displayed. Nov 2, 2011 at 18:02
  • 2
    Well, the answer isn't quite correct but it helped me find the correct answer. I guess the lightdm configuration has some script hooks. In particular I used display-setup-script=/home/cheshirekow/Codes/shell/xorg/setwacom.sh which worked. I found the answer here: askubuntu.com/questions/63681/… Nov 2, 2011 at 20:32

Try insert your script in ~/.xprofile file, like below

#! /bin/sh
# ~/.xprofile: execute commands at the beginning of the X user
#              session - before the window manager is started.
# The xprofile files are natively sourced by the following
# display managers:
#     GDM     - /etc/gdm/Xsession
#     LightDM - /etc/lightdm/Xsession
#     LXDM    - /etc/lxdm/Xsession
#     SDDM    - /usr/share/sddm/scripts/Xsession
# More in https://wiki.archlinux.org/index.php/Autostarting

/usr/bin/nm-applet &
  • Thank you. This worked for me. May 2, 2021 at 11:33
  • I was initially using a ~/.xsession but that only runs once when the display server first runs (hence a window manager reload does not trigger it) but this solves the issue!
    – usersina
    Mar 11 at 9:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .