I got it working in the end by adding the release
modifier to the xbindkeys config. I have no idea why the press event doesn't work but the release event does.
The final xbindkeys config ended up being:
"xte 'keydown Alt_L' 'key F1' 'keyup Alt_L'"
release + b:10
evrouter
can help to do that. It will even allow to release G9 before selecting the task from the list.
http://www.bedroomlan.org/projects/evrouter
I've built it from source and installed with checkinstall
, but there is something that looks like a repository there.
Hooks
It can be configured in the ~/.evrouterrc
:
"Logitech Gaming Mouse G300" "/dev/input/event.*" any key/272 "SHELL//home/velkan/click.sh"
"Logitech Gaming Mouse G300" "/dev/input/event.*" any key/275 "SHELL//home/velkan/atab.sh"
Running sudo evrouter -d /dev/input/event*
and clicking around will help to compose these lines.
"Logitech Gaming Mouse G300"
is the name of my mouse.
"/dev/input/event.*"
means that input will be intercepted regardless of the name of device file to which the mouse is bound.
any
- means that the event will be accepted with any Alt/Ctrl/Shift modifier.
key/272
- left mouse button.
key/275
- back mouse button (on G4 for me).
"SHELL//home/velkan/click.sh"
- run /home/velkan/click.sh
when that event occurs.
Alt-Tab scripts
So, the /home/velkan/atab.sh
script (that is bound to G4 in this case):
#!/bin/bash
mktemp /tmp/evr-alt-tab-XXXX
/usr/bin/xte 'usleep 100000' 'keydown Alt_L' 'usleep 50000' 'key Tab'
It creates a temporary file that will inform the click.sh
(bound to the left button) that it needs to release Alt.
click.sh
script:
#!/bin/bash
if [ -e /tmp/evr-alt-tab-???? ]; then
/usr/bin/xte 'usleep 100000' 'keyup Alt_L'
rm /tmp/evr-alt-tab-????
fi
Activating evrouter on startup
Haven't tried that on KDE.
Launch script /usr/local/sbin/evrouter_launch.sh
:
#!/bin/sh
/usr/local/bin/evrouter /dev/input/event* 0<&- > /dev/null
(or it may be /usr/bin/evrouter
instead of /usr/local/bin/evrouter
)
Config /etc/lightdm/lightdm.conf
to start evrouter with the desktop manager:
[SeatDefaults]
autologin-user=
session-setup-script=/usr/local/sbin/evrouter_launch.sh
Best Answer
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:
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.
This tool allows you to use bind keyboard and mouse keys to shell commands.
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.
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.
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:
Open a terminal and enter this command
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.
Open a terminal and enter this command:
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.
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.
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:
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
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:
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”.
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:
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.