Monday, July 1, 2013

Configure Logitech MX Revolution Mouse in Arch/Manjaro Linux

I switched over to Arch and spent a long time trying to get my mouse working properly. Here is a quick and easy guide to getting Logitech MX Revolution mouse working.

Install the needed software
# pacman -S  xbindkeys xvkbd xautomation

- xbindkeys is a program that allows you to launch shell commands with your keyboard or your mouse under X Window. It links commands to keys or mouse buttons, using a configuration file.

- xvkbd is a virtual (graphical) keyboard program for X Window System which provides facility to enter characters onto other clients (softwares) by clicking on a keyboard displayed on the screen.

- xautomation Control X from the command line for scripts, and do "visual scraping" to find things on the screen. The control interface allows mouse movement, clicking, button up/down, key up/down, etc,


Edit you xorg.conf file
# /etc/X11/xorg.conf

Insert this text in the mouse section
   Section "InputDevice"
       Identifier  "Mouse0"
       Driver      "mouse"
       Option      "Protocol" "auto"
       Option      "Device" "/dev/input/mice"
       Option      "ZAxisMapping" "4 5"
       #Option      "XAxisMapping" "6 7"  #uncomment if you want horizontal scrolling with mouse wheel
       Option      "Buttons"    "17"
   EndSection


Create your xbindkeys configuration file
# touch ~/.xbindkeysrc

Edit your xbindkeys configuration file
#   ~/.xbindkeysrc

Here is my file:
# forward
"/usr/bin/xvkbd -text "\[Alt_L]\[Left]""
m:0x0 + b:8

# back
"/usr/bin/xvkbd -text "\[Alt_L]\[Right]""
m:0x0 + b:9

# next tab
"/usr/bin/xvkbd -text "\[Control_L]\[Page_Up]""
m:0x0 + b:13

# previous tab
"/usr/bin/xvkbd -text "\[Control_L]\[Page_Down]""
 m:0x0 + b:15

# undo closed tab
"/usr/bin/xvkbd -text "\[Control_L]\[Shift]\[t]""
 m:0x0 + b:16

# mouse wheel left middle click
"xte 'mouseclick 2'"
b:6

# mouse wheel right middle click
"xte 'mouseclick 2'"
b:7


- I used xvkbd to emulate key combinations on my controller
 and xte to emulate middle click
- use these examples to configure your own system


I didn't enjoy the search button so I turned it into a middle click button also

Add the foll0wing to
# /etc/sysctl.conf

# Enable mouse button emulation
dev.mac_hid.mouse_button_emulation = 1
# Set 2nd button to 217 - the middle button of MX Revolution mouse.
dev.mac_hid.mouse_button2_keycode = 217



Here is a reference for all the MX Revolution
   # b:1    -    left mouse button
   # b:2    -    left and right mouse button together
   # b:3     -    right mouse button
   # b:4    -    mouse wheel up
   # b:5    -    mouse wheel down
   # b:6    -    mouse wheel left
   # b:7    -    mouse wheel right
   # b:8    -    back button
   # b:9    -    forward button
   # b:10    -    -none-
   # b:11    -    -none-
   # b:12    -    -none-
   # b:13    -    media wheel up
   # b:14    -    -none-
   # b:15    -    media wheel down
   # b:16    -    -none-
   # b:17    -    media wheel press