How to assign "back" and "forward" actions to Logitech Anywhere Mouse MX' horizontal scroll wheel?

15,135

Solution 1

I use xbindkeys in combination with xdotool.

Create a .xbindkeysrc file in your home directory. It must contain:

# Mapping BACK to mousewheel left on old Logitech
"xdotool key Alt_L+Left"
m:0x0 + b:6

# Mapping FORWARD to mousewheel right on old Logitech
"xdotool key Alt_L+Right"
m:0x0 + b:7

However with VMware you don't have to do anything else except adding

mouse.vusb.enable = "TRUE"

to the .vmx file in your host system. It's what VMware opens every time you start your guest system.

Solution 2

I have this same mouse, and I wanted to bind the two buttons on the side of the mouse to forward and back. Here is how I solved this:

1) Use the utility "xev" to determine what numbers the buttons you are wanting to remap correspond to. You may have to install this package using

sudo apt-get install xev  

Once xev is installed type "xev" into a terminal, and an X window that is white with a black box will pop up. Moving your mouse into that window will begin registering events to the terminal. Reading the output of that carefully will tell you the numbers of your mouse buttons. On my mouse, the left and right tilt map to buttons 6 and 7 respectively.

2) Now we are going to use the utility "xbindkeys" to remap the mouse buttons to key presses. If you don't already have this installed you may have to install it with

sudo apt-get install xbindkeys

3) Create a file in your home directory called ".xbindkeysrc". This is what xbindkeys will read to see what you are remapping. The contents of my .xbindkeysrc file are:

 "/usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
   m:0x0 + b:8

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

So this tells my computer to send the keyboard button presses "Alt+Left" or "Alt+Right" to the system using the virtual keyboard (xvkbd) whenever button 8 on mouse 0 is pressed or button 9 on mouse 0 is pressed respectively. These keys correspond to the the forward and back keys in most applications. This will work, for example, in Nautilus, chrome/

Note: you may need to install xvkbd if not already present on your system. sudo apt-get install xvkbd

Solution 3

Here is what I did. No sudo commands or new packages necessary:

  • I tested my buttons with xev --> all buttons correspond to a certain value, which means they are recognized by the system
  • inspect devices with xinput list --> the mouse is listed with ID 9 in my case
  • xinput list-props 9 shows current mapping and especially tells about button labels --> seems like foreward / backward corresponds to button 8 and 9 which I do not have (wheel tilt is 6 and 7 and mapped to horizontal scrolling)
  • remapping bindings via xmodmap as interpreted by X is most convenient solution for me. First five buttons should not be changed (left right middle click and scolling up and down), but those reporting as button 6 & 7 should navigate foreward / backward
  • executing xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7 10 11 12 13 14 15 16" in a terminal swaps buttons 6 and 7 with 8 and 9 (virtually)
  • if this mapping does not work for you restore defaults with xmodmap -e "pointer = default" and try a different mapping
  • Now I have the button swap command in my Startup Applications to be executed after login
  • it also seems possible according to man xmodmap to store this command in a file called ~/.xmodmaprc or append the instruction to ~/.bashrc

Worked for me. Hope this helps.

Solution 4

This is what worked for me:

1) Install xbindkeys

sudo apt-get install xbindkeys

2) Install xautomation

sudo apt-get install xautomation

3) Create a file .xbindkeysrc in your home directory with this inside:

# History Back & Forward
"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L' "
  b:6
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L' "
  b:7

4) Go to Startup Applications and add program with xbindkeys command.

5) Log out & log in

Source: Ubuntu Forums

Solution 5

Easystroke is, well easy to configure.

sudo apt-get install easystroke
Share:
15,135

Related videos on Youtube

ysap
Author by

ysap

I've been a computers/computing enthusiast since many years ago. Started coding FORTRAN on punched cards, then moved to BASIC on my MC6809 based DRAGON-64 and then the x86 IBM-PC era. I had the opportunity of working on mainframes, minis, workstations, PC's and embedded hardware. Today I am doing mainly embedded coding - C and ASM on various processors, and on various programming environments and toolchains like MS Visual Studio, Eclipse CDT, ARM DS and more. Was lucky enough to be at the right time at the right place to get to work as a VLSI designer for a top tier chip company, working on a world class processor family. Always looking to solving problem in the most elegant way! - Yaniv Sapir

Updated on September 18, 2022

Comments

  • ysap
    ysap over 1 year

    I am using a Logitech Anywhere Mouse MX on my Ubuntu. Mouse works well, but I can't assign the actions to the extra buttons available on it. What I miss the most is the "back" and "forward" actions assigned to the scroll wheel tilt left and right.

    How can I activate these features?

  • ysap
    ysap over 12 years
    Thanks. Running the xev utility I do see lots of info, however, although the scroll up and down functions are mapped to keys 4 and 5, I do not get any event when I tilt the scroll wheel, nor when I click the two side buttons. Any ideas why?
  • jarvisschultz
    jarvisschultz over 12 years
    It's possible that for some reason your system doesn't recognize the signals sent from the mouse. If this is the case, you should see error codes either in /var/log/messages or in dmesg. Read more about this problem and how to fix it at this url jveweb.net/en/archives/2011/01/… If that is not the problem, we will have to look into it more.
  • ysap
    ysap over 12 years
    ok, I looked at the dmesg log. it is a pretty long list of messages. What exactly should I be looking for?
  • ysap
    ysap over 12 years
    BTW, I did not mention it in the question but it may help - I am using Ubuntu as a guest OS on VMware Player on Windows 7. From my experience with a few devices, the emulation is pretty good, do Ubuntu should definitely see all messages sent by the mouse.
  • jarvisschultz
    jarvisschultz over 12 years
    look at the link I posted previously to see what you should be looking for in dmesg. You could try piping the dmesg output to grep with something like dmesg | grep key, or you could monitor the /var/log/messages with tail -f /var/log/messages I'm not sure if the Windows/ virtual machine setup you've got going is causing problems. It's certainly possible
  • ysap
    ysap over 12 years
    In the log files I see no trapping of the required mouse actions. Same as with xev, where I see the left and right buttons events, as well as the scroll wheel events, but not the tilt nor the side buttons.
  • ysap
    ysap over 11 years
    Thanks, B-Scan. I assume you meant the file to be put in my home directory. I placed it there and added a xbindkeys entry to Startup Apps, logged out and in and... it does not work :-(
  • B-Scan
    B-Scan over 11 years
    Yes, home directory. Now I saw that you are using VMware. Maybe could be related to this?
  • ysap
    ysap about 11 years
    Thanks. I will test the vmx line next time I restart the system (doesn't happen too often).
  • ysap
    ysap about 11 years
    Just tried the vmx file hack - and it doesn't seem to work. What I see is that when I do a restart, VMware erases the line I just added, as if it has a default file template that is being reset every time you start the machine.
  • ysap
    ysap about 11 years
    ok, it looks like I had to go all the way and shut down the machine, rather than just restart. Now the settings is preserved. Unfortunately, working remotely right now, the mouse wheel seem ineffective (same on the host machine). I'll check again when at the remote site and report the results.
  • ysap
    ysap about 11 years
    Oh yeah - just checked, and it works!
  • MestreLion
    MestreLion over 10 years
    +1: This xmodmap approach worked immediately for me, but... is it possible to modify mapping for a specific mouse?
  • c_korn
    c_korn over 10 years
    Could it be possible a sudo apt-get install xvkbd is missing here?
  • Hosam.Yousof
    Hosam.Yousof over 8 years
    Obviously, you need to run xbindkeys after the setup.