5

I am running Ubuntu 15.04 on a Dell XPS 13 from 2013. Since 13.04 I sometimes get accidental middle clicks/middle click emulation. I can tell this is happening because text in my clipboard pastes itself (default behaviour on Ubuntu) at random times.

Can anyone tell me why this is happening and how I can disable it?

hellocatfood
  • 3,379

2 Answers2

12

Run the following command:

xmodmap -e "pointer = 1 25 3 4 5 6 7 8 9"

To persist this behavior, edit ~/.Xmodmap and add

pointer = 1 25 3 4 5 6 7 8 9
Maythux
  • 87,123
1

For Ubuntu 18.04 and later (which have middle mouse button emulation enabled by default):

Create a script called disable-middle-button-emulation with following contents:

#!/bin/bash

to through all input devices

xinput list --id-only | while read id do # if this device supports middle button emulation, disable it (both evdev and libinput variants) xinput --list-props "$id" | grep -qF "Evdev Middle Button Emulation" && xinput set-prop "$id" "Evdev Middle Button Emulation" 0 xinput --list-props "$id" | grep -qF "libinput Middle Button Emulation" && xinput set-prop "$id" "libinput Middle Button Emulation" 0 xinput --list-props "$id" | grep -qF "libinput Middle Emulation" && xinput set-prop "$id" "libinput Middle Emulation" 0 done

Then run chmod a+x disable-middle-button-emulation to set execute enabled bit and then you can run it with ./disable-middle-button-emulation. If you put the file in your home directory under subdirectory bin, you don't need to prefix the command. As an alternative, you can put all of the above in file ~/.xsessionrc which gets automatically executed whenever you start a new X session.

To verify the system behavior (before or after the above change), run xev, move mouse pointer over the xev window and press both left and right buttons simultaneously. If you get "button 2" (middle mouse button) in the terminal output, emulation is still active. You should get separate events for "button 1" (left mouse button) and "button 3" (right mouse button). Note that if the simulation is active, the event from pressing mouse button 1 or 3 down will be delayed 50 ms which causes extra lag for everything in the system. If you truly want to use emulation but reduce lag, you can modify the above script to look for Button Emulation Timeout and adjust it to your liking. The default value is 50 which means 50 ms.