24
submitted 1 month ago by DarkSpectrum@lemmy.world to c/linux@lemmy.ml

I am a new Linux user and have settled on Ubuntu 24.04.3 LTS in Wayland. In Windows, I used AutoHotKey to automate the keyboard to type repetitive text strings with a hotkey e.g. pressing Alt+E to type my@email.com

I believe the solution in Linux is to install an application like dotool or ydotool and then create a custom shortcut command. The problem is I cannot get dotool and ydotool to work. I'll document the issues I'm having with ydotool as there seems to be more awareness and support for this application.

I am following the instillation instructions here:

https://askubuntu.com/questions/1413829/how-can-i-install-and-use-the-latest-ydotool-keyboard-automation-tool-working-o

Everything seems to go fine until I get to this step and get the following error:

sudo systemctl enable ydotoold

Failed to enable unit: Unit file ydotoold.service does not exist.

I came across this issue which suggests it could be a permissions issue on /dev/uinput and tried to the solution provided in that post but I still can't enable ydotoold after a reboot.

Running this command works:

ydotoold --version

v1.0.4-38-g708e96f

But I am stuck here and not sure how to troubleshoot or progress further. Any help would be appreciated, thank you!

top 16 comments
sorted by: hot top new old
[-] zstg@programming.dev 9 points 1 month ago* (last edited 1 month ago)

Perhaps it's a user-level service? Try systemctl --user start ydotoold.service

[-] DarkSpectrum@lemmy.world 3 points 1 month ago

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 abcde12345

It will miss the first few characters and type:

de12345

When I try chaining shell commands to pause and wait before typing, it doesn't work at all:

sleep 2; ydotool type abcde12345

Any ideas on how I could automate ydotool as a keyboard hotkey? Custom shortcut to run a bash script maybe?

[-] med@sh.itjust.works 3 points 1 month ago

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 abcde12345

Or 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.

[-] DarkSpectrum@lemmy.world 1 points 1 month ago

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.

[-] bigpEE@lemmy.world 2 points 1 month ago

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

[-] DarkSpectrum@lemmy.world 1 points 1 month ago

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.

[-] hades@feddit.uk 4 points 1 month ago

It looks like you’re missing the ydotool.service unit file in the package. Can you check by running dpkg -L ydotool-custom (the name of the package you chose in step 3.4)?

Unit files are how services are defined in most Linux-based desktop systems, similar to services in Windows.

[-] DarkSpectrum@lemmy.world 4 points 1 month ago

Thanks for the reply Hades, the output of that command is:

/.

/usr

/usr/lib

/usr/lib/systemd

/usr/lib/systemd/user

/usr/lib/systemd/user/ydotoold.service

/usr/local

/usr/local/bin

/usr/local/bin/ydotool

/usr/local/bin/ydotoold

/usr/local/share

/usr/local/share/man

/usr/local/share/man/man1

/usr/local/share/man/man1/ydotool.1.gz

/usr/local/share/man/man8

/usr/local/share/man/man8/ydotoold.8.gz

[-] hades@feddit.uk 8 points 1 month ago* (last edited 1 month ago)

Ah okay, it’s a user unit then. Try the following:

$ systemctl --user enable ydotoold
$ systemctl --user start ydotoold
[-] magitian@programming.dev 4 points 1 month ago

It doesn't appear to have had updates recently, but wtype might do the trick.

[-] just_another_person@lemmy.world 2 points 1 month ago

Project looks dead, and last commit was 2 years ago. Probably just some incompatible difference between a modern build and whenever the last work was done on it.

Read the real docs and repo though, not just somebody's post about it: https://github.com/ReimuNotMoe/ydotool

[-] vort3@lemmy.ml 2 points 1 month ago

Not a solution you want, but consider custom compose key sequences for repetitive text.

[-] Auster@thebrainbin.org 2 points 1 month ago

I remember coming across a tool for Linux which works somewhat similar, Iirc called AutoKey (I remember the name confusing both me and Google, so that's probably it). However, AutoHotKey uses its own language and as is more popular, it has more materials available, while AutoKey uses Python but last I checked, it was hard finding anything, so raw Python knowledge may be needed.

[-] clmbmb@lemmy.dbzer0.com 1 points 1 month ago

Give keyd a try. It works great for me.

[-] Overdraft@lemmy.ml 1 points 1 month ago

Reading through the comments, it seems like you've got ydotool working, but it may not have all the capabilities you want. I created a tool that seems like it could do everything you need, it has a couple of prerequisites, but it runs as a python script and doesn't require super user to work.

If you wanted to give it a go, I'd be happy to help as much as I can; I use it daily on Debian 12 with Wayland, so I'm pretty confident it should work for you on Ubuntu. Admittedly, it's still rough around the edges, but it can definitely handle mapping 'Alt + E' to type an email address.

https://gitlab.com/sincere-untimely-yesterday-group/custom-input-remapping/-/tree/7d64cfd2cb70c5acc19ba7536b91f9558e69b9ce/

[-] db2@lemmy.world -4 points 1 month ago* (last edited 1 month ago)

Wayland doesn't do any of the things you want here. X11 has problems but it's also mature and works. You'd have xdotool and already be done.

this post was submitted on 05 Jan 2026
24 points (100.0% liked)

Linux

62451 readers
476 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

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS