Notes for Ubuntu 21.04, getting the MX Master mouse to work.
- Ubuntu 21.04 uses Wayland by default. These instructions only work for x.org
- Getting Wayland to rebind mouse keys was confusing. Much easier to just use x.org and these instructions I found.
First, install Solaar to see the battery level on the taskbar
sudo apt-get install solaar
To remap the keys, install
sudo apt-get install xbindkeys xautomation xdotool
Then, launch xev to get the keyboard or mouse event to bind
xev
# grep button
xev | grep -i button
Create the configuration file for xbindkeys
nano ~/.xbindkeysrc
Here is an exemple of this file that map the Back and Forward buttons to BackSpace and Return respectively
# thumb wheel up => increase volume and unmute
# using xdotool pops up the Ubuntu OSD for volume
"xdotool key XF86AudioRaiseVolume"
b:7
# thumb wheel down => lower volume
"xdotool key XF86AudioLowerVolume"
b:6
# backward button => previous song
"xte 'key XF86AudioPrev'"
b:8
# forward button => next song
"xte 'key XF86AudioNext'"
b:9
# Example backspace
#"xte 'keydown BackSpace'"
#b:8
#"xte 'keyup BackSpace'"
# b:8 + Release
# Alt tab to previous app
"xte 'keydown Alt_L' 'key Tab' 'keyup Alt_L'"
b:9
To test your binding
xbindkeys -v
To start xbindkeys
xbindkeys
To find key code
xbindkeys --key
// or
xbindkeys --multikey
If you change the key map, you have to restart xbindkeys by following command
killall xbindkeys && xbindkeys