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?

  • 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 8 '15 at 9:32

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
  • 4
    This works like a charm! Mind to explain what it does? – h3nr1x Jan 12 '18 at 13:15
  • 1
    @h3nr1x I found some related info here – gregn3 Apr 20 '18 at 18:55
  • Also see xmodmap and this askubuntu.com/questions/749660/… – Kerem Dec 5 '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 9 '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 8:32

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:


# to through all input devices
xinput list --id-only | while read id
    # 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

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.

  • 1
    That worked nicely. Of note, I did have to change the second grep line to xinput --list-props "$id" | grep -qF "libinput Middle Emulation" && xinput set-prop "$id" "libinput Middle Emulation Enabled" 0 to get it to work. – BrainStorm.exe Oct 31 '20 at 5:46
  • Thanks for extra info, I added that to the answer. Which Ubuntu version do you have? – Mikko Rantalainen Nov 2 '20 at 14:09
  • It was Linux Mint, but I don't recall which version off hand. I will check when I get home. – BrainStorm.exe Nov 2 '20 at 16:17

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