I was calibrating my touch screen, and saw that the best tool around was xinput_calibrator. So I used it. It have two options (one of which did not work), so I am here for the second. It says I should execute this command "in a script that starts with your X session":

xinput set-int-prop "3M 3M USB Touchscreen - EX II" "Evdev Axis Calibration" 32 14410 2146 14574 2115

So I tried ~/.xinitrc, ~/.xsession and ~/.xsessionrc, all of which did not exist. So I created them and the exact content was this command. The first two files made my logins fail (after I login, I fall back to the login screen).

With the last file, the calibration was functional, but only after logging in...

I need that command to run before the login dialog shows up. I thought of adding this command to the end of /etc/X11/xinit/xinitrc with no result (nothing changed). Also, I tried to add it to the end of /etc/X11/Xsession.d/40x11-common_xsessionrc (after inspecting some of the files), but the result was exactly the same as adding it to ~/.xsessionrc.

How can I make this command run before the login screen shows (is this before the window manager starts, or before the X session starts)?

(I am running Kubuntu with the default window manager, if that matters)

UPDATE As I am using Kubuntu, my display manager is kdm. As the accepted answer suggests, I edited the file /etc/kde4/kdm/Xsetup, and as mentioned here I added the command before the command that is there by default. And it works like a charm :)


All the files you tried to change are read after you log in. Furthermore, ~/.xinitrc and ~/.xsession are the full set of commands that run in a session; ~/.xinitrc is read if you run xinit or startx from a text mode prompt, and ~/.xsession is read if you run a “custom session” (the name may vary) from a graphical login prompt.

You need to configure your display manager, the program that shows the login prompt. For kdm, the KDE display manager, add your command to /etc/kde4/kdm/Xsetup (or /etc/kde3/kdm/Xsetup for older versions) (that's the path on Debian, I haven't verified that Kubuntu uses the same path).

For gdm (the Gnome display manager), add your command to /etc/gdm/Init/Default. For xdm (the traditional X display manager), add your command to /etc/X11/xdm/Xsetup.

|improve this answer|||||
  • Thanks for the explanation! I tried what you suggested without success. I located the Xsetup file (in the same path you mentioned) and added the command. The calibration did not work, but I made sure it was executed, by adding echo "w" > /test.log, and verifying /test.log did exist after reboot. Is it possible that xinput requires special "context" or something... ? – jadkik94 Jul 10 '12 at 21:11
  • Actually, disregard the last comment. I redirected the xinput command to that file, and it seems I had added a space to the device name which made the calibration not work. You were 100% correct :) Thanks again. – jadkik94 Jul 10 '12 at 21:19
  • 5
    And just to complete the answer - to find out what is your display manager (not to be confused with a desktop environment) use: cat /etc/X11/default-display-manager. – Nux Oct 23 '12 at 9:12
  • What about xserverrc? And the ones that are in /etc/X11/xinit/xserverrc? – CMCDragonkai Aug 26 '16 at 10:38
  • 1
    @CMCDragonkai If there's a display manager, startx is not used. Display manager initialization scripts would not be relevant here since they run before the user logs in. – Gilles 'SO- stop being evil' Aug 26 '16 at 13:32

I suggest that you create your own config file, a simple example:



Section "InputClass"
         Identifier "Calibration"
         MatchProduct "3M 3M USB Touchscreen - EX II"
         Option "Calibration" "14410 2146 14574 2115"

That should do the trick.

|improve this answer|||||

You could try /etc/rc.local ?


|improve this answer|||||
  • 4
    I was concerned the script would run before X even starts (as I understood it), which would render that script useless... When does this run? – jadkik94 Jul 8 '12 at 21:03
  • 3
    @jadkik94 you are right this won't work as rc.local doesn't have access to the x session. – Ulrich Dangel Jul 8 '12 at 23:04

When you have OpenSUSE you can copy your script to /etc/init.d and run insserv script name. insserv enables a script: http://man-wiki.net/index.php/8:insserv.

|improve this answer|||||
  • 2
    This probably won't work as xinput needs probably X which is not available/initialized in the init scripts – Ulrich Dangel Jul 8 '12 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.