this post was submitted on 05 Jan 2026
24 points (96.2% liked)
Linux
61979 readers
1932 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
That seems to have worked better, I can now run ydotool commands in terminal. Will a user level service have any specific limitations?
When use this command as a custom keyboard shortcut:
ydotool type abcde12345It will miss the first few characters and type:
de12345When I try chaining shell commands to pause and wait before typing, it doesn't work at all:
sleep 2; ydotool type abcde12345Any ideas on how I could automate ydotool as a keyboard hotkey? Custom shortcut to run a bash script maybe?
I think ydotoold has an equivalent to sleep built in. A good while back I wrote a quick ydotoold command to automate something like 100 keypresses with delays in between. Let me know in 12 hours if you haven't gotten that figured out and I can find you the commands
Thanks, unfortunately ydotool has removed their sleep command stating 'this should be your shell's job'. I tried using the standard shell sleep command and used the semicolon to chain commands. Maybe thats not how to use the command field of the custom shortcut.
Oh, oh I know this one!
If your keyboard shortcut contains control characters, it will be interpreting the keypresses with the control characters you're holding for the shortcut. Alt+a super+b etc.
Some keyboard shortcuts trigger on press, they can also trigger on release. This is why you need the sleep statement, to give you time to release the keys before it starts typing. You want the shortcuts to trigger after release.
I can set the difference in my window manager, but I'm not sure about doing it in (GNOME?) Ubuntu. Even assuming you can set the shortcut to only run on release, you still need to let go of all the keys instantly, so chaining with sleep is probably the best approach.
Chaining bash sleep and ydotool works for me in my window manager. Consider using "&&" instead of ";" to run the ydotool type command. Whatever is written after the "&&" only executes if the previous command (sleep 2) succeeds. The ";" might be interpreted by the keyboard shortcut system as an end of the statement:
sleep 2 && ydotool type abcde12345Or perhaps the shortcut system is just executing the programs, not necessarily through a bash shell. In that case we would need to actually run bash to use its sleep function and the ";" or "&&" bit. Wrapping the lot in a bash command might look like this:
bash -c "sleep 2 && ydotool type abcde12345"Assuming that doesn't work, I see nothing wrong with running a script to do it. You just need to get past whatever in the shortcut system is cutting off the command after the sleep statement.
Running ydotoold at user level is preferred and recommended. It keeps it inside your user context, which is better for security.
This worked for me:
bash -c "sleep 2 && ydotool type abcde12345"Thank you! I couldn't find any good instructions for the Command field of custom keyboard shortcuts.