7

I have a Logitech G500 mouse which has a third button between the usual "backward" and "forward" mouse buttons.

I want to bind the GNOME-Shell activies overview to that button button.

I tried to do that in the Keyboard settings where under "system" the action "show the activities overview" is available, but when I press the mouse button it remains "disabled".

1

1 Answer 1

8

Copied from a Bohemian Blog post (dead now, Wayback Machine link) in case it dies:

Gnome 3: Activate Overlay and More by Mouse Button

I would like to activate the “Gnome 3/Shell Overlay” with the click of an otherwise-unused mouse button. As I posted earlier, Gnome 3 does not currently have any ability to assign actions/functions to mouse buttons. But there is a way to make it work using xdotool and xbindkeys. Thanks to AlphaLux (see comment below) I was able to replace my earlier easystroke solution with xbindkeys.

There’s also a program called easystroke that employs mouse gestures for executing shortcuts. The only reason I know this is because someone smarter than myself described the solution on the Ubuntu Forums. So, to “stinkeye” of the magical land of “Woop Woop”, I bequeath a laurel . . . and hearty handshake for answering this question about keyboard and mouse shortcuts in Gnome 3. Though I am including two solutions below, I recommend the xbindkeys solution.

First, descriptions of what xdotool, xbindkeys and easystroke do:

xdotool

This tool is invisible. You will not directly use it. But it will give you the ability to compose a commandline instruction for telling your computer that a button or group of buttons have been pressed. There is more to it than that, but for our purposes that’s all that matters.

xbindkeys

This tool allows you to use bind keyboard and mouse keys to shell commands.

easystroke

This tool allows you to use “mouse gestures” to submit commands to your computer. Mouse gestures are akin to the “touch gestures” that are an important part of newer touch interface computer systems like Apple’s iOS and even OSX via their ever-growing touchpads as well as Android, Windows Phone 7, etc. etc. The instructions below will be using this program to merely press a mouse button. I won’t be talking about gestures today.

Making a Mouse Button Make Things Happen with xbindkeys

As described above my only motivation for this functionality is to summon the Gnome Shell Overview. The directions below will describe how to do that. Feel free to substitute your own functionality as you see fit. Hopefully the instructions will be written in a clear enough way as to make that easy to do.

  1. AssignKeyboard Input to the Desired Functionality

System Settings > Keyboard > Shortcuts In my case I set Show the activities overview to the Menu key, because I use the Super/Windows key for Third- and Fourth-level switching.

  1. Install xdotool and xbindkeys

You’ll have to figure out the best/easiest way to do this for your flavor of Linux. If you are running Ubuntu you can install them via the Software Center or:

sudo apt-get install xbindkeys xdotool
  1. Determine Mouse Button Identity with xev

Open a terminal and enter this command

xev

Xev will create a small, empty window. Hover your mouse over this window and click the various buttons on your mouse. After you click xev will tell you the identity of that button. Now that you know their identities we can use xbindkeys to associate them with shell commands.

  1. Configure xbindkeys

Open a terminal and enter this command:

gedit ~/.xbindkeysrc

and press Enter. This will open the xbindkeys configuration file in Gedit. It should be a blank file. Add the following to the document and save.

# Gnome Shell Mouse Button 8 to Overview
"xdotool key Menu"
release + b:8

The above configuration sets the mouse button 8 to activate the Gnome Shell Overview. The first line is a comment to help you remember what this setting does. The second line defines the shell command to be enacted within double quotes. The third line defines the button action, in this case upon the release of the mouse button 8 the command will be executed.

  1. Set xbindkeys to autostart on login

From the Gnome Shell Overview > Applications list, look for “Startup Applications” and start it. After the application window appears click the Addbutton. You can title the entry whatever you want, but “xbindkeys” is nice and concise. Most importantly though, enter the following into the Command input:

xbindkeys &

Once correctly entered, click OK and then Close. Now xbindkeys will automatically start upon logging in.

Making a Mouse Button Make Things Happen with easystroke

  1. Install xdotool and easystroke

You’ll have to figure out the best/easiest way to do this for your flavor of Linux. If you are running Ubuntu you can install them via the Software Center or:

sudo apt-get install easystroke xdotool
  1. Easystroke Preferences

Start Easystroke. Go to the Preferences tab. Under the Behavior section, click the Gesture Button button. Move your cursor to the empty gray space in the resulting window and click the mouse button that you would like to associate to activating the Gnome Shell Activities Overlay (or whatever you are trying to do at the click of a mouse button). Once you click you should see a change in the settings at the bottom of the small window. In my case I have a Logitech laser mouse and I am using “Button 8”. Also under the Appearance section check the option “Autostart Easystroke”.

  1. Create New Easystroke Action

Go to the Actions tab. Click the Add Action button. Name the action “Overlay via Mouse”. The Type should be “Command” and the Detailswill be:

xdotool key Menu
  1. Associate Mouse Button to Easystroke Action

In Easystroke highlight your new “Action” by clicking on it. Click the Record Stroke button. Move your cursor to the small resulting window and click the desired mouse button. Click the Yes button to confirm your mouse button input. Click the Hide button when you are finished.

Again, unless you specifically want to use mouse gestures, I think xbindkeys is a better, more responsive solution than easystroke. You should be able to test this fancy new functionality immediately. If not, try logging out and logging back in. Enjoy.

2
  • While it's possible to open the activities overview with the xbindkeys method, closing it does not work in Ubuntu 18.10 (and Fedora). Have a look at this issue. Also, on Ubuntu 18.10 xbindkeys is automatically creating an autostart entry in gnome-session-properties, so step 5 can be omitted.
    – DMT
    Nov 26, 2018 at 18:21
  • Brilliant Answer. Thank you for taking the time to write it! :) Dec 15, 2020 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .