4

I'm running Openbox 3.5.2 (on Lubuntu 13.10) by logging into Openbox session.

In an Openbox session, if I run xdotool mousemove 1000 5 click 3 from a terminal, the mouse cursor moves to the specified blank position on the desktop; then a mouse right-click is executed to open the right-click menu of Openbox.

So I made the following keybind in ~/.config/openbox/rc.xml:

<keybind key="W-space">
  <action name="Execute">
    <command>xdotool mousemove 1000 5 click 3</command>
  </action>
</keybind>

and reconfigured Openbox. But when I press super+spacebar all I see is that the mouse cursor moves to the designated position; the right-click menu doesn't appear.

How can I cause the right-click menu to appear?

1

You should try and wait until the mousemove has completed, sometimes things get out of sync if your system is slow. You can put in a delay ( with sleep or xdotool's own --delay. That always delays and slows down things. You should therefore first try:

xdotool mousemove --sync 1000 5 click 3

As --sync doesn't wait if nothing needs to be done. If that doesn't help you can alwasy put in an extra delay with sleep:

xdotool mousemove --sync 1000 5
sleep 0.2
xdotool click 3
  • xdotool mousemove 1000 5 click 3 works when run from the terminal; so I don't think it's an issue of system speed. xdotool mousemove --sync 1000 5 click 3 gives the same result. – user15760 Jan 20 '14 at 10:25
  • But I made a bash script of your last suggestion, the one with sleep, and that worked from inside rc.xml. – user15760 Jan 20 '14 at 10:32
  • @vasat it was never completely clear to me what happens with --sync, sometimes it seemed to help sometimes not. I don't like to put in sleep statements, but when they are necessary then it must be. – Timo Jan 20 '14 at 11:29
  • Yes, I left out --sync and things work fine. I tried reducing sleep's value but at some point it became touch-n-go depending, I guess, on what else was going. – user15760 Jan 20 '14 at 11:43
1

The problem is that the click is executing before you release super, and Openbox distinguishes between a click and modifier+click. The cleanest solution is to use xdotool to also send a keyup event:

xdotool mousemove 1000 5 keyup Super_L click 3

Using sleep as Timo suggested also works as long as you release super before sleep returns (thus the hit or miss success with a lower sleep value).

While probably not relevant in your case, if you wanted to execute another keystroke using super immediately after xdotool returns, without releasing and repressing the key, you can put a keydown event later in the command. In my testing I have been unable to release the key faster than xdotool executes, and the keydown event helps to ensure expected behavior.

  • +1 My tint2 start menu is complete... (it uses xprop for the _NET_WORKAREA atom) – user42117 Oct 11 '14 at 10:05
0

If you only want to show the Openbox menu when you press super+spacebar then you could do it with just

<keybind key="W-space">
  <action name="ShowMenu">
    <menu>root-menu</menu>
  </action>
</keybind>

This works all the time even if you have a window in fullscreen.

Your Answer

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