Mouse text selection to paste buffer using middle click

Background

I have a Logitech Marble Mouse Trackball, with its scrolling ability configured as follows:

#!/bin/bash

dev="Logitech USB Trackball"
we="Evdev Wheel Emulation"
xinput set-int-prop "$dev" "$we Button" 8 8
xinput set-int-prop "$dev" "$we" 8 1

This allows me to hold down the small left-button and scroll by rolling the trackball up and down, with side-to-side motions having no effect.

This is a clean install of Xubuntu 12.04 LTS running Xfce.

Problem

Using Kubuntu (and many other desktop environments), I was able to:

  1. Select text with the mouse (either by dragging the selection or double-/triple-clicking words).
  2. Middle-click (emulated as the small right-button) to paste in another window (or the same window).

I have tried to re-enable the behaviour using:

  • http://who-t.blogspot.ca/2011/04/gnome-30-middle-mouse-button-emulation.html
  • marble mouse middle click fail in 12.04
  • https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/874237/comments/13

Running gsettings set org.gnome.settings-daemon.peripherals.mouse middle-button-enabled true returns No such schema 'org.gnome.settings-daemon.peripherals.mouse'.

The dconf-editor tool does not show org::gnome::settings-daemon::peripherals::mouse. The closest I could find is org.gnome.desktop.a11y.mouse, but it does not have a setting for middle-button-enabled.

Question

How do I enable "middle-click" for the trackball so that the small right-button performs a paste of the copy buffer?


Configuration

Following these instructions and this answer and this document:

  1. Do not execute the script shown in the question.
  2. Edit /usr/share/X11/xorg.conf.d/10-evdev.conf.
  3. Append the following lines:
    Section "InputClass"
        Identifier  "Marble Mouse"
        MatchProduct "Logitech USB Trackball"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "ButtonMapping" "1 9 3 4 5 6 7 8 2"
        Option "EmulateWheel" "true"
        Option "EmulateWheelButton" "8"
        Option "ZAxisMapping" "4 5"
        Option "XAxisMapping" "6 7"
        Option "Emulate3Buttons" "true"
    EndSection
    
  4. Save and restart X.

Restart X

Enable Ctrl-Alt-Backspace to restart X as follows:

echo setxkbmap -option terminate:ctrl_alt_bksp >> ~/.xprofile
chmod +x ~/.xprofile
~/.xprofile

This:

  1. Sets the small left button as the wheel activator (click and hold to scroll).
  2. Sets the small left button as the "back button" (click, no scroll).
  3. Sets the small right button as middle-click to paste.
  4. Enables horizontal and vertical scrolling.
  5. Disables both large buttons as chord-click.

Addendum

After rebooting restarting X, I found the scrolling no longer worked, possibly due to an upgrade. If this happens to you, try:

  1. Remove the following files (I moved mine to ~/.):
    /usr/share/X11/xorg.conf.d/50-vmmouse.conf
    /usr/share/X11/xorg.conf.d/50-marblemouse.conf
    /usr/share/X11/xorg.conf.d/11-evdev-quirks.conf
    
  2. Remove any additional mouse input device settings from:
    /etc/X11/xorg.conf
    

Verification

Verify the settings using (where 8 is the device number; yours will likely vary):

xinput get-button-map 8