Gnome Shell Overview with a mouse click on Ubuntu

Some weeks ago I’ve bought a new keyboard and mouse combo, the Logitech MK710 keyboard with the Logitech M705 optical mouse. This is a tremendously nice combination, that much that I’ve actually bought another combo to use at home.

Mouse Logitech M705 in Ubuntu, using all buttons

As a Gnome Shell user, I wanted to take advantage of the side-button the mouse has. Is that little line you see in the image above. So my idea was to trigger the Overview mode with this button, as if the Windows (or Super) key was pressed.

Gnome Shell Overview

So, how to do this under Ubuntu 13.10? Essentially by binding the button to a command. That command will execute an action, which is “press a key”

First, install the following packages: xbindkeys xautomation

Then, use the xev command to find the number of the mouse button. For that, run xev, press the button and take note of the value. When running xev, a little white box will appear. Put the mouse in the box and press the button. In the terminal -xev needs to be called from a terminal, did I forget to mention that?- you’ll see some output similar to this:

ButtonPress event, serial 33, synthetic NO, window 0x3c00001,
root 0x28d, subw 0x0, time 89142314, (89,93), root:(2011,171),
state 0x10, button 10, same_screen YES

ButtonRelease event, serial 33, synthetic NO, window 0x3c00001,
root 0x28d, subw 0x0, time 89142454, (89,93), root:(2011,171),
state 0x10, button 10, same_screen YES

What matters is the “button 10” part.

Now, we’ll need to bind the “button 10” to a key. This can not be done directly. What we can do is to bind a key to a command, this is execute a command when the key is pressed. Then, we can make the command to be a “send key” command.

To test it, first type this in the console

xte 'key Super_L'; sleep 1; xte 'key Super_L';

You should see the Overview mode, and after one second it will revert back. If this works, now we can bind the keys. We’re going to use xbindkeys for this. If there’s no configuration file, most likely this is the case for you, you can create a default one by typing

xbindkeys --defaults > $HOME/.xbindkeysrc

Then edit this file with your favorite editor, and add this

"xte 'key Super_L'"
b:10+release

“b:10” is the button you’ve found before. The +release is to trigger the command when the button is released and not when it’s pressed.

Last, you’ll want to execute xbindkeys on every start. For this, you might create an entry in the ~/.config/autostart folder named “xbindkeys.desktop” with the following content:

[Desktop Entry]
Name=XBindKeys
Comment=XBindKeys
Exec=/usr/bin/xbindkeys
Icon=solaar
StartupNotify=false
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

Now you can log out, log back in, and enjoy your new button!