Pages - Menu

Sunday, March 11, 2012

mapping middle-click to a keyboard key under fedora

By far the most popular post on this blog was my old mapping middle-click to a keyboard key trick, which worked well under Ubuntu at the time.

Since then I've switched to Fedora which doesn't package old X11 tools like xkbset. However, this is such a useful thing to have on a laptop I've found a way.

We'll need the xdotool package, so yum install xdotool.

Then under the settings of your Window Manager, simply create a shortcut to xdotool click 2.

Under the default Gnome 3 desktop, this is in the Keyboard page of gnome-control-center.

Under Openbox, we'd add an entry to rc.xml like this
<keybind key="Menu">
  <action name="Execute">
    <command>xdotool click 2</command>
  </action>
</keybind>
And we're done!

xdotool can actually do a whole heap more than just emulate keyboard and mouse events, check out the author's webpage for more info!

6 comments:

Kenneth Skertchly said...

Thanks for your post. I read your previous article and everything worked great except for the numpad. Now this new method also works, but it sends multiple keystrokes if the button is held down. Do you know if there's a way to make it behave like it did with xmodmap?

Jamie said...

I'm not sure, sorry. I guess the graphical environment is reading the repeating keypress and running the command each time.

However, I have since discovered that Fedora does contain xkbset in the "xkbset" package, and xmodmap in the "xorg-x11-server-utils" package, so you might be able to still use the old method?

The numpad might not have worked because you still had numpad directions mapped to mousekeys to move the cursor. Make sure you delete all those in the old mousekeys file.

Anonymous said...

In case you run some other window manager, try

xdotool click --clearmodifers 2

if it doesn't work.

Anonymous said...

Hi I am extremely happy with your old method and thank you for posting it:

I run

setxkbmap -layout de
xkbset m
xkbset exp =m# map keysym to other keysym
xmodmap -e "keysym Menu = Pointer_Button2"

on a eeepc and on a TravelMate 2350. However, on the latter it happens erratically (usually between 30 and 200 minutes after startup) that all of a sudden the mouse pointer moves to the upper right corner wildly blinking and whenever I try to move it, it immedately moves back. The only remedy is a hard reboot as I cannot move the mouse reliably. After rebooting it works again for some minutes or hours.

This happend under Ubuntu 14.04 and after a new install also under Lubuntu 15.04. There are no other problems whatsoever.

I suppose it must be hardware-related but: What is the reason, how can one avoid it? Any idea?

Thanks a lot, D-E

Jamie said...

Maybe try turning the trackpad off and on again? There's usually a hardware button for it, or if it's a Synaptics pad then you can use "synclient". Just bind a keyboard combination to a script which disables the pad, sleeps for 1, then re-enables the pad.

Anonymous said...

Hi Jamie,
thanks for the hint! I added to the script:

................
while true
do
sleep 100
synclient TouchpadOff=1
synclient TouchpadOff=0
done

so far I have no more encountered the problem with the mouse pointer I described for the Travelmate 2350 and everything seems to work perfectly!

I am only wondering where the problem came from

Thanks again