22

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 :)

2
  • 4
    What login manager are you using? For gdm3 you can probably use /etc/gdm3/Init/display or /etc/gdm3/Init/Default - manpages.debian.net/cgi-bin/… Commented Jul 8, 2012 at 23:08
  • Hey, good stuff. I've posted a question here [unix.stackexchange.com/questions/172007/… which got marked as a possible duplicate to this Q&A. However, folks, am not convinced it's a clone. Pl see my question too and help me out :)
    – kaiwan
    Commented Dec 8, 2014 at 7:36

4 Answers 4

15

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.

7
  • 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
    Commented Jul 10, 2012 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
    Commented Jul 10, 2012 at 21:19
  • 7
    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
    Commented Oct 23, 2012 at 9:12
  • What about xserverrc? And the ones that are in /etc/X11/xinit/xserverrc? Commented Aug 26, 2016 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. Commented Aug 26, 2016 at 13:32
4

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

/usr/lib/X11/xorg.conf.d/20-calibration.conf

Filecontent:

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

That should do the trick.

-1

You could try /etc/rc.local ?

.

2
  • 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
    Commented Jul 8, 2012 at 21:03
  • 3
    @jadkik94 you are right this won't work as rc.local doesn't have access to the x session. Commented Jul 8, 2012 at 23:04
-1

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.

1
  • 2
    This probably won't work as xinput needs probably X which is not available/initialized in the init scripts Commented Jul 8, 2012 at 23:04

You must log in to answer this question.

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