Customizing Mouse Buttons With Linux

In this quick-and-dirty guide we’re using xvkbd to make our mouse buttons do strange and beautiful things.


Install xbindkeys and xvkbd:

sudo apt install xbindkeys xvkbd

Use xev to detect the correct buttons:

xev | grep ', button'

Create .xbindkeysrc in your home directory:

touch ~/.xbindkeysrc

Edit .xbindkeysrc:

nano ~/.xbindkeysrc
# Button 10 smashthat PageDown fam
"xvkbd -text '\[Page_Up]'" # Sends PgUp
b:10
# Button 11 smashthat PageUp fam
"xvkbd -text '\[Page_Down]'" # Sends PgDn
b:11

Reload the config file:

killall -s1 xbindkeys

Start xbindkeys:

xbindkeys -f ~/.xbindkeysrc

Pgup & Pgdn all the things!


Turn the ball into a scroll wheel:

xinput set-prop "pointer:ELECOM TrackBall Mouse HUGE TrackBall" 'libinput Button Scrolling Button' 12

xinput set-prop "pointer:ELECOM TrackBall Mouse HUGE TrackBall" 'libinput Scroll Method Enabled' 0 0 1

Now the trackball will act as a scroll wheel when button the is pressed.


Check out the xvkbd tutorial on xahlee for additional mouse shenanigans.

 

1 Comment
  1. I have defined a few buttons on my mouse this way and they work fine. However, I can’t get the “Shift” key mapped to the remaining button. Can you help or point me in the right direction. Thanks.

Leave Your Reply