Why do these xte commands work in terminal, but not when bound with xbindkeys?
This xte
command, when I run it in a terminal, triggers Expo mode:
xte 'keydown Super_L' 'key S' 'keyup Super_L'
However, when I put this in my .xbindkeysrc file:
"xte 'keydown Super_L' 'key S' 'keyup Super_L'"
b:11
Nothing happens when I click the button. The following binding makes the letter X appear in my console when I press button 11:
"xte 'key X'"
b:11
So why doesn't the Expo binding work?
This is the verbose output of xbindkeys -n -v
when clicking button 11:
Button press ! e.xbutton.button=11 e.xbutton.state=16 "xte 'keydown Super_L' 'key W' 'keyup Super_L'" m:0x0 + b:11 (mouse) got screen 0 for window 2bb Start program with fork+exec call Button release ! e.xbutton.button=11 e.xbutton.state=16
And nothing happens. Does this have anything to do with the way xbindkeys
executes the command? (fork+exec call)
Attempt number two.
expo.sh:
#!/usr/bin/env bash
export DISPLAY=:0
xte 'keydown Super_L' 'key S' 'keyup Super_L'
Executing this script from the command line activates Expo. Binding it in xbindkeys:
"sh ~/expo.sh"
b:11
Clicking mouse button 11:
Button press ! e.xbutton.button=11 e.xbutton.state=16 "sh ~/expo.sh" m:0x0 + b:11 (mouse) got screen 0 for window 2bb Start program with fork+exec call
Nothing happens!
Another simpler solution: instead of using just "b:11" in the xbindkeys definition, use "b:11 + release". It will wait until you release the button to fire the command.
Example:
"sh ~/expo.sh"
b:11 + release
This is very weird. It turns out that if my mouse button is still pressed (not yet released) when the Super+W
keystroke is simulated, nothing happens. I don't know who to blame for that (perhaps Cinnamon?). I have worked around it though, by adding a short delay to the xte
command:
xte 'usleep 100000' 'keydown Super_L' 'key S' 'keyup Super_L'
It now waits 0.1 seconds before simulating Super+S
. If I press and hold the mouse button more than 0.1 seconds, nothing happens.
This is a workaround answer. I'd much prefer a proper answer.
I faced the same problem.
"xte 'key b'"
was working in the console but not in the xbindkeys parameter file. I changed b by his keysym code, using the "xev" command to obtain it :
"xte 'key Ox62'"
It worked for me
Try with +Release
"xte 'keydown Super_L' 'key S' 'keyup Super_L'"
b:11 + Release
That may help.
Have similar issue while using sxhkcd keymapper. It turns out your actual shortcut keys are detected as still being pressed.
There are some semi-workarounds:
- look for the release event
- add
sleep 0.2
in front of your command - use shortcut with leader-key
- release your shortcut modifiers in front of your xte sequence
However you cant get realtime actions with that =)