-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add xdotool type --aftermodifiers
option
#406
base: master
Are you sure you want to change the base?
Conversation
This waits for the user to release any modifier keys that are currently held before starting to type. This allows avoiding race conditions when xdotool is called from a keyboard shortcut, and starts to type characters with the modifier still held. Currently the usual way to do so is with --clearmodifiers, but this introduces its own race conditions (see e.g. issue jordansissel#43) if the physical key is released while the typing is in progress.
Hmm, the same issue probably also applies to |
I like this idea! This feels like a safer alternative to `--clearmodifiers`
I haven’t tested it yet, but the code looks good 👍🏻
I would welcome this feature for the `key` command also, as you suggested.
…On Sat, Oct 15, 2022, at 12:36 PM, Emily Ellis wrote:
Hmm, the same issue probably also applies to `xdotool key` et al. If this approach is okay with you, I'll go back and add those too (and also update the manpage).
—
Reply to this email directly, view it on GitHub <#406 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABAF2VI2UIENMJXCT5IZZLWDMBSDANCNFSM6AAAAAARGA67LU>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
…ers, and add it to the manpage
I coincidentally stumbled upon this problem too today, however one thing I don't understand @scgtrp:
this is true, but I have noted this has nothing to do with modifier keys. It seems that xdotool cannot send any key, while the issuing shortcut key is still held. In particular, this means e.g. when you configure a desktop environment shortcut on key press a with its action being In other words, what kind of desktop environment are you using? |
My DE is xfce + i3wm. The specific issue that led me here was fdw/rofi-rbw#56 - as far as I know, that's not a grabbed key binding, but just a normal key sequence going into that application's window that happens to close the window and execute xdotool in quick succession before I can release the alt key. I did just try binding a key to this in the XFCE application shortcuts thing, though, and it seems to work. Specifically, I bound |
ah, I see now. In your example, the grabbing problem I described doesn't apply because by use of
However, I should probably open up a new issue for this. In my project which does also some grabbing, I solved this now by going the route of Regarding your PR, I think it's definitely useful and should be merged. As I understand it, you're waiting and polling for the pressed modifiers 33 times a second. This seems like a reasonable approach, unless X11 offers another api that doesn't involve polling. |
Ah, yes, I can almost reproduce that: for me, any I actually settled on this after getting halfway through a much more overengineered solution involving grabbing all the modifier keys and waiting for KeyRelease events on them. I'm not actually sure it would have worked, and there's precedent for the polling-every-30ms approach in the other (* which I discovered last night by idly wondering if I could bind a command to shift-letter, trying it, forgetting I'd done so, and then later trying to start an email with "Hello" and getting the much less formal "ELLOello" instead) |
@phil294 I have a hypothesis that this was usually due to the way bindings work with XGrabKeyboard and XUngravKeyboard — but I don’t remember if I’ve tested that idea. That said, I’d welcome an issue about the problem you’re having — maybe there’s a better way to solve this than what I’ve recommended historically which is to add a short sleep before sending keys/typing? like maybe xdotool could detect if the x11 keyboard is grabbed and wait until it’s ungrabbed? I haven’t looked at this in a while, which is a good reason as any to revisit! ;) |
So I just hacked together a The other half-caveat is that I managed to forkbomb myself by binding I've pushed that change here so people can play with it. |
It’s still on my todo list to play with this more. I haven’t used my Linux workstation in a few weeks so it may be some time before I get to test. I’d welcome any others to test and provide feedback about the behavior improved by this patch! |
This sounds like a really good way to solve that problem, so I'm waiting for the merge 😉
That, however, doesn't sound so good. For example, in the mentioned rofi-rbw, I know neither the shortcut nor the typed letters, so it's impossible to make sure that this doesn't happen. Wouldn't it suffice to check that all keys are release once, and then not check again? It seems that the current implementation is less of a |
It does wait only once, unless I'm misunderstanding what you're saying here. I suspect (but haven't checked) that this can happen today, if you have a binding on a bare character or shift+character and that character is in the password you selected. I'm not really sure what to do about that, because there's no mechanism to make an Unrelated to that, it may be cleaner to add an |
What I meant was that once all keys have been released, it should not lock/wait again. For example, if the keybinding is |
It does that (with all keys, not just the keybinding, because it doesn't know what the keybinding was): if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
// ...
for (i = 0; i < data_count; i++) {
// type some text
} |
Hotkey + Send works together great now. ref jordansissel/xdotool#210 (comment), jordansissel/xdotool#406 (comment)
Any chance for this being merged? I think it's a great solution for #43. At least for an use case of assigning xdotool to a keyboard shortcut. |
This waits for the user to release any modifier keys that are currently held before starting to type. This allows avoiding race conditions when xdotool is called from a keyboard shortcut, and starts to type characters with the modifier still held. Currently the usual way to do so is with --clearmodifiers, but this introduces its own race conditions (see e.g. issue #43) if the physical key is released while the typing is in progress.