Bind your spare mouse buttons to useful Plasma features
I have a Logitech mouse with more buttons than I would ever use for most purposes. Unfortunately binding mouse buttons to shortcuts has been on the wishlist for over a decade! There is however a straightforward workaround in X-windows called xbindkeys. These instructions should work for most systems. Remember to add xbindkeys to your autostart list. https://help.ubuntu.com/community/KeyboardShortcuts
Keybindings can be configured in ~/.xbindkeysrc, which I've reproduced here:
# Previous Activity
"qdbus org.kde.kglobalaccel /component/plasmashell invokeShortcut 'previous activity'"
b:8
# Next Activity
"qdbus org.kde.kglobalaccel /component/plasmashell invokeShortcut 'next activity'"
b:9
# Show desktop grid
"qdbus org.kde.kglobalaccel /component/kwin invokeShortcut 'Expose'"
b:10
# Close
"xte 'keydown Control_L' 'key w' 'keyup Control_L'"
b:13
The first two entries bind my back and forward mouse buttons to switch through activities. Now that they're only a mouse button press, I switch activities far more frequently than I click "back" on my browser.
The third binds a window switcher to one of the thumb buttons. This one is pure eye candy. This screenshot is from KDE4 but the idea is the same. I recently switched to Kubuntu 15.10 Beta with Plasma 5.4 and find that this shortcut has become much more reliable.
These D-Bus commands correspond to the Global Keyboard Shortcuts in the System Settings, but the names are not always obvious. You can get a list of the available D-Bus shortcuts by running this in a shell:
qdbus org.kde.kglobalaccel /component/kwin shortcutNames | sort
Finally the fourth entry sends a Ctrl+W keystroke. It requires the xte program from the xautomation package. Unlike the D-Bus commands, this naively substitutes my button press into a raw keystroke, which sometimes produces unintended behavior. I would love to have a more robust solution which could e.g. send a different command based on the active window. Let me know in the comments!
Posted Sep 30, 2015, 6:37 PM UTC · edited