10

On my Thinkpad I need to execute something like this in the terminal:

xinput set-int-prop "TPPS/2 IBM TrackPoint" "Evdev Middle Button Emulation" 8 1

so that my the 2 buttons on my touchpad emulate the middle mouse click. Now I need this line to be executed each time I start GNOMe or X or whatever, so that it "just works".

I tried ~/.xsession or ~/.bashrc but to no avail. Should I put it in GNOME start scripts or in /etc/X somewhere?

I'm using Ubuntu 11.10.

michuk
  • 233
  • 1
  • 2
  • 7

4 Answers4

7

I'm using Enlightenment DM, but that's relevant to other DMs/desktops. I start my session using xsession so I initially put xinput commands in ~/.xsession which didn't change all settings I wanted to change. Only some of them. I was expecting either all or no changes, so I added a 10-interation loop to my .xsession with 1 second intervals, running xinput commands each time and checking if the settings were applied. To my surprise, all settings were applied after the first iteration.

This means that it's your DM that does something to override your xinput settings and since the command that launches your DM (E17 in my case) is the last one in your .xsession file, this file is no place for this.

I've added the following lines in my ~/.profile and this has solved the problem:

# don't run unless we're being invoked from an xwindows session
if [[ -n ${DISPLAY} ]]; then

  # set your devices names here
  pointer1="IBM TrackPoint"
  pointer2="Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint"
  pointer3="Logitech USB Trackball"

  id1=$(xinput | awk -F= "/$pointer1.*pointer/ {print \$2}" | cut -f1)
  id2=$(xinput | awk -F= "/$pointer2.*pointer/ {print \$2}" | cut -f1)
  id3=$(xinput | awk -F= "/$pointer3.*pointer/ {print \$2}" | cut -f1)

  if [[ -n "${id1}" ]]; then
    xinput --set-button-map "${id1}" 1 2 3 4 5 6 7
    xinput set-prop "${id1}"  "Evdev Wheel Emulation Axes" 6 7 4 5
    xinput set-prop "${id1}"  "Evdev Wheel Emulation" 1
    xinput set-prop "${id1}"  "Evdev Wheel Emulation Button" 2
    xinput set-prop "${id1}"  "Evdev Middle Button Emulation" 0
  fi

  if [[ -n "${id2}" ]]; then
    xinput --set-button-map "${id2}" 1 2 3 4 5 6 7
    xinput set-prop "${id2}"  "Evdev Wheel Emulation Axes" 6 7 4 5
    xinput set-prop "${id2}"  "Evdev Wheel Emulation" 1
    xinput set-prop "${id2}"  "Evdev Wheel Emulation Button" 2
    xinput set-prop "${id2}"  "Evdev Middle Button Emulation" 0
  fi

  if [[ -n "${id3}" ]]; then
    xinput --set-button-map "${id3}" 1 2 3 4 5 6 7 8 9
    xinput set-prop "${id3}"  "Evdev Wheel Emulation Axes" 6 7 4 5
    xinput set-prop "${id3}"  "Evdev Wheel Emulation" 1
    xinput set-prop "${id3}"  "Evdev Wheel Emulation Button" 8
    xinput set-prop "${id3}"  "Evdev Middle Button Emulation" 1
  fi
fi

PS. set-int-prop has been deprecated in favour of set-prop (man xinput).

Hopefully this helps someone.

  • The script is nice, but unfortunately it doesn't me give a solution. For now the only method works, if I run the terminal and then run the 'xinput set-prop' with the required options. I tried Marcin's script, Startup Application but those didn't work unfortunately. – Geeocode Jul 10 '17 at 22:21
  • "set-int-prop has been deprecated in favour of set-prop" T•H•A•N•K• •Y•O•U• – Clément Dec 20 '17 at 22:46
4

Add the command directly to startup applications. In the command field.

or

make a simple script and add the script to startup applications.

NickTux
  • 17,539
3

Create a file in /etc/X11/Xsession.d/ for it.

  • For me that was /etc/X11/xinit/Xsession – Thomas Ahle Aug 03 '12 at 14:19
  • 4
    I generally don't encourage making user-specific configuration changes in a system-wide configuration file. Firstly because it creates an additional thing to remember about when you need to migrate to a different machine and secondly, because these files are mostly there to provide sane defaults.

    It's nice to be able to just take the snapshot of your $HOME and the list of installed packages with you when you need to reinstall/migrate.

    – Marcin Kaminski Oct 17 '12 at 00:26
1

This is how I did it in Ubuntu 14.04 from the terminal:

1) Check the name of your device:

xinput list

2) See available options for your device:

xinput list-props "Your Device Name"

3) Edit settings (to make settings consistent after reboot/shutdown just add this command to Startup Applications):

xinput set-prop "Your Device Name" "Option Name" "Value"

Here is an example command I used to activate locked drags in my touchpad:

xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Locked Drags" 1

To activate/change another option just look for it in your device available options and play with them until you get the desired result, then add the command to Startup Applications and you're done! Hope it helps! : )

Marco
  • 991
  • 9
  • 13