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.
  2. 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
  3. 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.

  4. 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.

  5. 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
  2. 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”.
  3. 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
  4. 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.

How to Switch from Unity to Gnome 3 on Ubuntu 11.10

I’ve been begrudgingly using Ubuntu Unity as my desktop environment since upgrading to Ubuntu 11.10 shortly after it was released. At the time of the upgrade I had hoped to jump into the shiny new world of Gnome 3 from the recently-near-perfected Gnome 2. The Gnome Shell looked very polished and sophisticated next to Unity. Especially the Unity Launcher and Application/Window switcher… every icon is highlighted with a border or background color… I frequently mistake which icon is active/highlighted.

Images above are from other sites:
Gnome 3 from gnomeshell.wordpress.com , Ubuntu Unity from ubuntuvibes.com

However, there were a few small details with Gnome 3 that I found frustrating and ultimately unacceptable:

  1. Adwaita, the default theme, had excessive amounts of chrome and seemed excessively bright. The default theme of this new version of Gnome was not all that bad, but it certainly wasn’t exciting or a massive step forward from Gnome 2. Ubuntu’s default theme seemed much more refined and distinct.
  2. The Shutdown Option was not available unless you pressed the Alt (or Shift?) key. If you didn’t realize this secret, you would only be able to put your computer in Suspend mode. Apparently the Gnome developers didn’t read any of the articles about how much power we are wasting with gadgets in standby mode. Way to be green.
  3. The top panel is too tall, the panel and Shell text is too big and, confusingly, the panel icons are too small.
  4. Wasted Screen Real Estate. Maximized windows have a too-tall title bar smashed up against a too-tall top panel. Next to Ubuntu Unity, which employs a global menu and a somewhat quirky but very efficient maximized title bar that merges with the top panel, this felt like a step back.
  5. No Application Menu. Launching an application went from taking two clicks to taking 4 or 5 clicks via Gnome Shell.
  6. No Native Appearance Adjustment. If I wanted a desktop environment that only gave me the option to use blue or graphite highlights, I’d go back to using OSX. At the moment the only way in Gnome 3 that an ordinary user can change their theme, font and font settings is via a hack called Gnome Tweak. It works well, but it’s interface is pretty raw and it’s not integrated with the new Gnome Systems Settings.
  7. No Custom Mouse Buttons. This is probably due to the fact that the Gnome developers are imagining that their interface is for computers with touch screens. (sarcasm) Most likely the functionality simply hasn’t been created yet, but it seems like customizing mouse buttons on Linux should be baseline functionality.

Many of these problems were due to Gnome 3’s relative immaturity. These details need to be carefully worked out. And the only way to get a lot of developers and users involved enough to care and get excited is to flip the switch and migrate everybody to the new environment. At least the early adopters, anyway.

The Rise of Shell Extensions

The good news is that Gnome has not been standing still. A new capability was recently enabled that has allowed hackers to correct some of the above problems. This new capability is called Gnome Shell Extensions. These Extensions make it possible to alter the way Gnome Shell looks and works. The available set of extensions is not very large at the moment, but a handful of good ones suggests just how powerful this new feature is. Shell Extensions are actually not new, but being able to install them easily IS. Check it out: https://extensions.gnome.org/

In a nut, Shell Extensions are now as easy to install as Firefox Addons via the above website. Actually, the Gnome folks have made something much better thanks to the fact that Gnome is a desktop environment. The website functions more like your very own Shell Extensions Control Panel. No downloading, just two clicks and the extension is enabled. Here’s a handful that I just installed:

  • Alternative Status Menu (adds “Power Off” and “Hibernate” options)
  • Jump Lists (advanced contextual menus for the Gnome Shell Launcher for recent docs, bookmarks, etc.)
  • Music Integration (an Ubuntu Unity-esque sound menu with music player controls)
  • No a11y (removes the accessibility settings icon from the top panel)

Now, after installing at least the above list of Shell Extensions, there are a few more small tweaks that I think really make Gnome 3 sing. Well, singing with a few missed notes here and there.

Remove Title Bar from Maximized Windows

Sure, you could set the top panel to autohide, but I personally like having the clock and system status indicators visible at all times unless I’m watching a video. Ubuntu Unity does a great job at this and since the usefulness of the title bar is completely diminished once there’s only one mostly-full-screen window, why not simply remove it on maximized windows?

Thankfully, somebody at apathyonline.net described how to decrease the height of the title bar on maximized windows. They explain how to do this for the Adwaita theme. However, I wanted to do this same thing for Ubuntu’s Ambiance theme and unfortunately all Gnome 3 themes are not made in the same way. If you’re a fan of Ambiance, here’s how to do it:

  1. Open a Terminal
  2. Enter:
    sudo gedit /usr/share/themes/Ambiance/metacity-1/metacity-theme-1.xml

    and click ENTER.

  3. Search for
    <frame_geometry name="geometry_maximized"

    and add the attribute and value

    has_title="false"

    to the frame_geometry element.

  4. Then, as one of the distance elements within the frame_geometryelement, make sure one looks like this:
    <distance name="title_vertical_pad" value="1"/>
  5. Save the document and quit the text editor application. You might need to restart Gnome to see the change.

This seems like such an obvious enhancement. I’m curious why the Gnome 3 developers didn’t think of it or decided against it. However, they are discussing how to eliminate the menu bar, so that’s interesting.

Install an Applications Menu Extension and/or Gnome Do

Along with the shell extensions that I mentioned above, there are also two extensions available that add an Applications Menu back to the top-left of the top panel. Both seem to employ the same menu drop-down, but the way they are accessed from the top panel differ:

  • Applications Menu Adds a small Gnome-Foot icon to the right of “Activities” that summons the menu on click.
  • Frippery Applications Menu Replaces “Activities” with the word “Applications” and inserts the logo-icon of your system in the left corner the way the Gnome 2 applications menu traditionally did.

Again, since Gnome 3 is apparently designed for computers with touch screens (sarcasm, can’t help it) the functionality of hovering has been demoted. So this application menu involves 3 instead of 2 clicks to start an application (if you know which section the application is in to begin with). So it’s not quite business as usual, but it’s close. And maybe the Gnome team is showing a lot of foresight in removing any primary functionality from the “hover” state.

I guess I’ve embraced the brave new world of Gnome 3/Unity enough that the Applications Menu mentioned above feels out of place in Gnome 3. I was already a big fan of Gnome Do and Docky in the Gnome 2 world (and originally Quicksilver on OSX). Although Docky is obviously getting pushed aside by Gnome Shell’s and Unity’s built-in launcher bars, I find that the functionality, appearance and interface of Gnome Do is very consistent with both Gnome 3 and Unity. Actually, Gnome Do’s functionality is also being pushed aside by the built-in search-and-launch functionalities in Gnome 3 and Unity but, Gnome Do is still so much faster than either of these. So I am using Gnome Do as my primary launcher until something better comes along.

Good Enough

Let’s take another look at my list of show-stopping problems:

  1. A Better-Looking Theme – The Ambiance theme from Ubuntu is an improvement over Adwaita in my opinion, but with the know-how to remove the title bar from any given theme you can certainly switch to whatever theme you prefer. Just be prepared to discover that not all themes define the height of the title bar in the same way.
  2. Shutdown and Hibernation Options Restored – Shell Extensions save the day.
  3. Top Panel Is Still Too Tall, Shell UI Seems Oversized – Strike 1.
  4. Title Bar Removed from Maximized Windows – See #1.
  5. Application Menu Restored (or Replaced by Gnome Do) – Shell Extensions save the day again.
  6. No Native Appearance Adjustment – Well, Gnome Tweak does the job for now.
  7. No Custom Mouse Buttons – Strike 2. Custom Mouse Button via xdotool and easystroke!
    I’m on a roll this weekend. Read about how to set up custom mouse button shortcuts in my next post.

So with a few extensions, additional applications and tweaks Gnome 3 is good enough to get work done. The lack of a mouse button shortcut for summoning the Exposé-like Shell Window Overview will continue to interrupt the way I work. Though Compiz feels like a massive kludge, it is a relatively mature kludge that supports mouse shortcuts. Since Unity is a Compiz plugin it can take advantage of Compiz’s maturity. But Compiz will always be a sort of stopgap, a great temporary fix that probably help spawn some of the new thinking about user interfaces that we are being experimented with in Gnome Shell and Unity. I’m sure that the thought and design that went into the foundation of Gnome 3 will continue to bear fruit, resulting in a useful and well-integrated desktop environment. At least I hope that’s the case!