You are not logged in.
Hi,
I am running Plasma and wayland and want to get ydotool to work.
I have installed it
Added user to the group "input"
Run the service as a user
systemctl --user enable ydotool.service
systemctl --user start ydotool.service
but then when I run
ydotool type TESTING
failed to connect socket `/run/user/1000/.ydotool_socket': Permission denied
Please check if the current user has sufficient permissions to access the socket file.
looking at the status of the service it is showing the following
× ydotool.service - Starts ydotoold service
Loaded: loaded (/usr/lib/systemd/user/ydotool.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sun 2023-04-09 17:55:09 AEST; 6min ago
Duration: 1ms
Process: 35418 ExecStart=/usr/bin/ydotoold (code=exited, status=2)
Main PID: 35418 (code=exited, status=2)
CPU: 1ms
Apr 09 17:55:09 arhclinuxT14 systemd[740]: ydotool.service: Scheduled restart job, restart counter is at 5.
Apr 09 17:55:09 arhclinuxT14 systemd[740]: Stopped Starts ydotoold service.
Apr 09 17:55:09 arhclinuxT14 systemd[740]: ydotool.service: Start request repeated too quickly.
Apr 09 17:55:09 arhclinuxT14 systemd[740]: ydotool.service: Failed with result 'exit-code'.
Apr 09 17:55:09 arhclinuxT14 systemd[740]: Failed to start Starts ydotoold service.
I am getting a bit lost now as the git-hub site mentions ydotoold needs to be running as well?
Offline
You need to run the service as systemwide/root not as a user-service.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I read in the wiki that it had to be run as a user service see here Automations
Automation
ydotool (ydotool) - Generic command-line automation tool (not limited to wayland). Enable/start the ydotool.service user unit. See ydotoold(8), ydotoold(1).
Regardless I had already tried it as a system wide service but see below.
systemctl --user disable ydotool.service
sudo systemctl enable ydotool.service
Failed to enable unit: Unit file ydotool.service does not exist.
I searched in "/usr/lib/systemd/system" for a ydotool.service but nothing is there.
There is one in "/usr/lib/systemd/user/" as a test I just copied that into the system directory, seems odd that this is not documented?
Now the service starts ok.
But I still have to run the command as "sudo" is it possible to run it as normal user?
● ydotool.service - Starts ydotoold service
Loaded: loaded (/usr/lib/systemd/system/ydotool.service; enabled; preset: disabled)
Active: active (running) since Mon 2023-04-10 09:01:28 AEST; 6min ago
Main PID: 40448 (ydotoold)
Tasks: 1 (limit: 36973)
Memory: 172.0K
CPU: 1ms
CGroup: /system.slice/ydotool.service
└─40448 /usr/bin/ydotoold
Apr 10 09:01:28 arhclinuxT14 systemd[1]: Started Starts ydotoold service.
ydotool click 0xC0
failed to connect socket `/run/user/1000/.ydotool_socket': Connection refused
Please check if ydotoold is running.
sudo ydotool click 0xC0
c0 110 (executes correctly)
Offline
man newgrp
?
Offline
Make sure ydotool is properly installed and the systemwide service is enabled and started. ydotool and ydotoold need root permissions to access the devices.
Running ydotool with sudo obviously is not practical, and hardly feasible in very likely circumstances, i.e., in scripts launched from shortcut keys. There will be better practices than that, but I solve this by setting the setuid bit on the executable:
sudo chmod +s $(which ydotool)
Then, ydotool started as user looks for the socket "/run/user/1000/.ydotool_socket" but the daemon as a systemwide service listenes to /tmp/.ydotool_socket. To make that work, you can link to the socket expected by ydotoold ("ln -s /tmp/.ydotool_socket /run/user/1000/.ydotool_socket"), but a way more elegant approach (in my opinion, that is), is to set the YDOTOOL_SOCKET variable during login: "YDOTOOL_SOCKET=/tmp/.ydotool_socket", e.g. in the bash profile file or systemwide.
Offline
I don't know your use case but I found dotool (https://git.sr.ht/~geb/dotool) simpler to use than ydotool
Offline
I was not aware of this tool, thanks!
Offline
I (only now) moved to dotool!
It is indeed a lot easier to use, allowing key names instead of codes, and not requiring to explicitly indicate pressing a key then releasing a key. This very much reduces the friction to create a quick ad-hoc keyboard macro to automate a repeating task. I also find it performs very reliably.
Another asset is that no pause is required when triggering a script through a shortcut key. Thus, macros can start instantaneously. It does not matter if you are still holding down shortcut keys when the script started.
Offline