Xfce Forum

Sub domains
 

You are not logged in.

#1 2011-09-18 17:16:04

cruxic
Member
Registered: 2009-04-15
Posts: 5

[Solved] Need help emulating keystrokes from "Application Shortcuts"

[Originally I posted this to the mailing list but got no response]

Hello all,

My new keyboard does not have an audio "Play/Pause" key.  However I've found a way to emulate it with this command:

   xdotool key XF86AudioPlay

Works great from the command line.  Now all I need to do is bind the above command to a keyboard shortcut.  I go to Xfce Settings Manager -> Keyboard -> Application Shortcuts and setup a binding.  It does not work.  I've proven that Xfce is executing my xdotool command but for some reason it has no effect.  It's as if the execution context is different when Xfce executes it.

Any thoughts?

Thanks
- Cruxic
(XUbuntu 10.04)

Offline

#2 2011-09-18 18:37:15

angstrom
Member
Registered: 2011-08-13
Posts: 267

Re: [Solved] Need help emulating keystrokes from "Application Shortcuts"

I don't use xdotool but if you want to debug why it doesn't work, try to embed your command in a script. Something like this :

#!/bin/bash
env > /tmp/log
pwd >> /tmp/log

xdotool key XF86AudioPlay &> /tmp/log

Run the script in a Terminal then run it by the Xfce Keyboard shortcut and compare the 2 log files.


Xfce is NOT Xubuntu. Bugs in Xubuntu don't mean that Xfce is buggy ...

Offline

#3 2011-09-19 17:57:13

cruxic
Member
Registered: 2009-04-15
Posts: 5

Re: [Solved] Need help emulating keystrokes from "Application Shortcuts"

Good idea, angstrom.  When XFCE executes the script there appear to be very few differences.  $USER is still me.  $PATH is different but still able to find the xdotool command.  $DISPLAY is the same.  In both cases xdotool exits with zero/success.  The only interesting difference I see is the lack of the $WINDOWID variable when XFCE executes it.

Thoughts?  I tried artificially exporting $WINDOWID in the script but it had no effect.

Last edited by cruxic (2011-09-19 17:58:57)

Offline

#4 2011-09-20 22:33:03

angstrom
Member
Registered: 2011-08-13
Posts: 267

Re: [Solved] Need help emulating keystrokes from "Application Shortcuts"

Uhm ... Maybe some conflict between the key stroke sent by xdotool and the key stroke that are currently active/down as use xfce keyboard shortcut. Have you try to ask developper of xdotool ? What happen when you run xdotool AND there are key on keyboard that are active ? Try to put a sleep command in the script ?


Xfce is NOT Xubuntu. Bugs in Xubuntu don't mean that Xfce is buggy ...

Offline

#5 2011-09-21 19:47:40

cruxic
Member
Registered: 2009-04-15
Posts: 5

Re: [Solved] Need help emulating keystrokes from "Application Shortcuts"

Brilliant!  The sleep command did it.  Apparently xdotool (or perhaps X itself) has trouble sending keystrokes if a real key is already down.  Thanks a bunch, angstrom!

Offline

#6 2011-09-21 22:32:46

angstrom
Member
Registered: 2011-08-13
Posts: 267

Re: [Solved] Need help emulating keystrokes from "Application Shortcuts"

You're welcome :-)


Xfce is NOT Xubuntu. Bugs in Xubuntu don't mean that Xfce is buggy ...

Offline

Board footer

Powered by FluxBB