Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mostlygeek/9304cddddcfeb59985d19cc72b2c2f91 to your computer and use it in GitHub Desktop.

Select an option

Save mostlygeek/9304cddddcfeb59985d19cc72b2c2f91 to your computer and use it in GitHub Desktop.
Custom keymap for Logitech MX Master 2S mouse on Ubuntu

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

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      
"amixer -D pulse set Master 4000+ unmute"
 b:6
                                        
# thumb wheel down => lower volume       
"amixer -D pulse set Master 4000-"       
 b:7
                                        
# backward button => previous song       
"xte 'key XF86AudioPrev'"                
 b:8
                                        
# forward button => next song            
"xte 'key XF86AudioNext'"                
 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment