How to get Logitech MX Anywhere 2 to work with Ubuntu

1. Bluetooth

Ubuntu can now normally pair with MX Anywhere 2 so you don’t have to care about this kind of stuff. Simply use bluetoothctl or GUI to connect it. But after that, open a console, run

hciconfig hci0 sspmode 1
hciconfig hci0 down
hciconfig hci0 up

otherwise it cannot work correctly. Don’t forget to check your adapter address and replace hci0 if needed.

2. Button Binding

  1. Open a console
  2. Run apt -y install xautomation xbindkeys to install dependencies
  3. Run xev | tee mouse.log and a black box will appear
  4. Move cursor into the black box, press all the function buttons in a certain order (don’t forget it!)
  5. Search mouse.log for ButtonPress and you’ll find the “state” and “button” for each of the buttons

For example,

ButtonPress event, serial 40, synthetic NO, window 0x7800001,
    root 0x1c9, subw 0x0, time 1311199, (71,71), root:(1201,100),
    state 0x10, button 9, same_screen YES

this is the scroll left button and the “state” of it is “0x10” and “button” is “9”

Then, edit ~/.xbindkeysrc to specify the bindings, this is my ~/.xbindkeysrc file:

"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'"
    m:0x10 + b:6
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L'"
    m:0x10 + b:7
"xte 'keydown Control_L' 'key F10' 'keyup Control_L'"
    m:0x10 + b:2
"xte 'keydown Alt_L' 'key F1' 'keyup Alt_L'"
    m:0x10 + b:9
"xte 'keydown Control_L' 'key F12' 'keyup Control_L'"
    m:0x10 + b:8

Finally, add /usr/bin/xbindkeys to auto-start program list, this depends on the desktop environment you use.

Refers:
http://askubuntu.com/questions/636712/logitech-mx-anywhere-2-mouse-pairs-but-doesnt-do-anything
https://wiki.archlinux.org/index.php/Xbindkeys
https://bbs.archlinux.org/viewtopic.php?id=119636#p938801

コメントを残す