Start the program xev
in a terminal. Move the mouse inside the xev
window; you'll see a lot of stuff scroll by. Press each button in turn. Then switch back to the terminal window and press Ctrl+C. xev
shows a description of each input event, in particular ButtonPress
and ButtonRelease
for mouse clicks (you'll also see a number of MotionNotify
for mouse movements and other events).
It's likely that your forward and back buttons are mapped to mouse buttons, maybe buttons 8 and 9:
ButtonPress event, serial 29, synthetic NO, window 0x2e00001,
root 0x105, subw 0x0, time 2889100159, (166,67), root:(1769,98),
state 0x0, button 8, same_screen YES
If that's the case, remap these buttons to a different action in your browser, if you can. Alternatively, you can remap the buttons to different button numbers which your browser doesn't react to or disable the buttons altogether at the system level. To do this, put these lines in a file called ~/.Xmodmap
:
! Remap button 8 to 10 and disable button 9.
pointer = 1 2 3 4 5 6 7 10 0
Test it with the command xmodmap ~/.Xmodmap
. Most desktop environments and window managers run this command automatically when you log in; if yours doesn't, arrange for it to run when X starts.
It's also possible that your mouse sends a keyboard event when you press these buttons:
KeyPress event, serial 32, synthetic NO, window 0x2e00001,
root 0x105, subw 0x0, time 2889100963, (957,357), root:(2560,388),
state 0x0, keycode 166 (keysym 0x1008ff26, XF86Back), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
In that case, put lines like these in ~/.Xmodmap
:
keycode 166 = NoSymbol
keycode 167 = NoSymbol
You cannot map two physical buttons to the same logical button. All you can do is swap the buttons (echo 'pointer 1 7 3 4 5 6 2' | xmodmap -
). This is a low-level limitation of X11. As stated in the documentation of XSetPointerMapping
:
However, no two elements can have the same nonzero value, or a BadValue error results.
The best you can do is to use a program like xbindkeys
to send a fake button 2 press when button 7 is pressed. In .xbindkeysrc
:
"xdotool mousedown 2"
b:7
"xdotool mouseup 2"
b:7 + Release
Best Answer
You can use
xbindkeys
to map the buttons to text that will trigger KDE shortcuts. However, that may interfere with Firefox's recognition of the buttons. You can use mouse gestures instead of buttons if that is a concern. Also, you should probably commont on this feature request to use mouse buttons as KDE shortcuts.