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
  • 1
    I'm also seeing this every once in a while on a Samsung NP300E5Z laptop. Rather than disabling, I'd be curious what's the exact action that triggers this. I'd like to use this feature on purpose, but I couldn't figure out how to trigger this. – egmont May 08 '15 at 09:32

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
  • 84,289
  • 5
    This works like a charm! Mind to explain what it does? – h3nr1x Jan 12 '18 at 13:15
  • 2
    @h3nr1x I found some related info here – gregn3 Apr 20 '18 at 18:55
  • Also see xmodmap and this https://askubuntu.com/questions/749660/how-can-i-persistently-remap-keys-in-ubuntu-16-04 – Kerem Dec 05 '19 at 11:56
  • 1
    this also disabled mouse middle click (not just touchpad) for me as well, not sure that's what I wanted. – Kerem Dec 09 '19 at 14:06
  • That command binds middle mouse button to mouse button 25 which definitely prevents middle mouse button from working but this doesn't actually prevent middle mouse button emulation which adds extra 50 ms delay to all mouse clicks by default. – Mikko Rantalainen Oct 13 '20 at 08:32
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.