Ydotool not working on Fedora 40?

I just installed ydotool, started the service as requested (systemctl start ydotool), and it is running without issues (systemctl status ydotool does say Active: active (running)), but whenever I try running ydotool, it fails with:

failed to connect socket `/run/user/1000/.ydotool_socket': No such file or directory
Please check if ydotoold is running.

I couldn’t find any relevant documentation or Google results about it. Well, actually I just found this one, but from 2023. If ydotool made it to Fedora 40, I’m assuming someone managed to make it work without sudo?

Note that my user is sudoer, but sudo ydotool does not work because I’m using it to activate a screen capture software, and if I run it as root, I just get a black screen. So it has to be run as normal user.

1 Like

ydotool - Fedora Packages says: “however, it generally requires root permission (to open /dev/uinput)

why that assumption?

Thanks, I hadn’t seen that page.

Actually, I found out here a solution that works for me:

export YDOTOOL_SOCKET=/tmp/.ydotool_socket
systemctl restart ydotool
sudo chmod 666 /tmp/.ydotool_socket

Now I can run ydotool without root and it works. Probably not ideal from a security perspective, but at least usable.

2 Likes

You can restrict access to the socket like this:

sudo dnf install ydotool
sudo tee /etc/profile.d/ydotool.sh << "EOF" > /dev/null
export YDOTOOL_SOCKET="/tmp/.ydotool_socket"
EOF
sudo mkdir -p /etc/systemd/system/ydotool.service.d
sudo tee /etc/systemd/system/ydotool.service.d/override.conf << EOF > /dev/null
[Service]
Group=input
ExecStart=
ExecStart=ydotoold -P 660
EOF
sudo systemctl daemon-reload
sudo systemctl enable ydotool.service
sudo systemctl restart ydotool.service
sudo usermod -a -G input ${USER}

Be sure to relogin or reboot to apply the changes.

2 Likes

Where do you put those lines?

Thanks.

terminal :sweat_smile:

It it’s okay to run ydotool with root, it’s easier to start the daemon with sudo ydotoold in a terminal and run commands in another with sudo ydotool key ...