Tuesday | 30 APR 2024
[ previous ]
[ next ]

ydotool

Title:
Date: 2024-01-02
Tags:  sysadmin

I'm happy that this tool works but I'm not happy that I got it working mostly by chance and hackery. I feel like I've misunderstood something about how wayland and ydotool interact.

Regardless, here is how I got it working. One thing to note is that if you did a bunch of package upgrades, reboot your machine. I had issues where the uinput device was not working and I didn't see it in the list of kernel modules. After rebooting however I did see it in the listing.

Check for uinput:

lsmod | grep uinput

If you don't get any output, it means it wasn't there.

Load it in:

modprobe uinput

Once that's done, you can then install ydotool, on arch:

pacman -Sy ydotool

Now this is where it get's finnicky. Trying to run ydotool and enabling the service results in some strange errors about permissions and who to run things as. Trying to run the utility as a regular user results in an error message telling you to run as root. Running as root results in the wrong socket file to get created. There is also no systemd service file for root.

The solution was to get into root and then create the service file.

Place the below in /etc/systemd/system/ydotool.service:

[Unit]
Description=Generic command-line automation tool

[Service]
ExecStart=/usr/bin/ydotoold --socket-path /tmp/.ydotool_socket --socket-perm 0666
Restart=on-failure

[Install]
WantedBy=default.target

I hardset the path and the socket permissions here, otherwise I wasn't able to get it to work.

Now you can start and enable ydotool.

systemctl enable ydotool.service
systemctl start ydotool.service

Now you can actually use ydotool:

YDOTOOL_SOCKET=/tmp/.ydotool_socket ydotool type "hello"

You need to set the environment variable to match the socket path from above.

These are the steps I used to get my [screenshoting] working.