I want to map various mouse actions to key presses using xbindkeys. All my attempts to do this in my .xbindkeysrc file have failed. Attempts have been made using xte and xdotool. Below is a summary of what has been tried - although I'd like to map several mouse actions so far I've just been trying to initiate a right-button mouse click.

The following xdotool and xte commands work perfectly when called from a terminal, from the graphical pop-up Run Command text-box, and from within a script called from the terminal and the Run Command text-box. It is only when called using keys set in the .xbindkeysrc file that they fail.

Entries from .xbindkeysrc:

"xdotool click 3"
    control + 8

"xte 'mouseclick 3'"
    control + 7

# -x :0 sets the display.
"xte -x :0 'mouseclick 3'"
    control + 6

# Starting a text editor window works fine.
    control + 1

I also had no luck placing the same commands (one at a time) in a script and calling that in .xbindkeysrc. I added a command at the bottom of the script to create a file - the file gets created every time so I know that the script is being run successfully.

    control + 5

Please note that there have been no silly mistakes like not restarting xbindkeys after making alterations, I've been checking that it is running and added a command to .xbindkeysrc which launches a text editor window so that I can be sure xbindkeys is running properly.

System Info.
OS:        GNU/Linux x86_64
Kernel:    3.13.0-24-generic
Distro:    Linux Mint 17 Qiana, Cinnamon 64-bit 2.2.16
           [Based On: Ubuntu 14.04.5 LTS, Trusty Tahr]
  • 1
    Just tested your first entry using xev; it works fine on my system. Which sequence of events do you see with xev for this entry (Ctrl-8)? – dirkt Nov 15 '17 at 18:54
  • I've put the xev output for the first 3 commands in a Github gist - it looks like the mouse event takes place but no right-click menu ever actually gets displayed. Any ideas? – mattst Nov 15 '17 at 19:28
  • 1
    Tested again with fvwm and firefox, right-click menu for the first entry (Ctrl-8), both menus appear. What applications did you use to test for a right-click menu? – dirkt Nov 15 '17 at 19:57
  • Various; Terminal, Sublime Text, Nemo, Firefox, the desktop. Why would the application make a difference? – mattst Nov 15 '17 at 20:53
  • 1
    Just trying to find a hint why it works on my system, but not on yours. I've honestly no idea where to look next. – dirkt Nov 15 '17 at 20:58

I resolved the problem after finding this post on Superuser. It says there is a bug which can be worked-around by adding a short pause. The following .xbindkeysrc entry now works.

"sleep 0.25 && xdotool click 3"
    control + 8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.