You are not logged in.

#1 2023-04-09 08:03:34

exup
Member
Registered: 2017-07-13
Posts: 23

Help with getting ydotool to work

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

#2 2023-04-09 13:40:14

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,550
Website

Re: Help with getting ydotool to work

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

#3 2023-04-09 23:15:58

exup
Member
Registered: 2017-07-13
Posts: 23

Re: Help with getting ydotool to work

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

#4 2023-04-10 11:38:23

dogknowsnx
Member
Registered: 2021-04-12
Posts: 648

Re: Help with getting ydotool to work

man newgrp

?


RI - Rest your Eyes and Self

"We are eternal, all this pain is an illusion" - Maynard James Keenan

Offline

#5 2023-04-22 13:01:30

yttrium
Member
Registered: 2017-02-19
Posts: 11

Re: Help with getting ydotool to work

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

#6 2023-04-22 14:34:14

galvez_65
Member
Registered: 2018-06-29
Posts: 20

Re: Help with getting ydotool to work

I don't know your use case but I found dotool (https://git.sr.ht/~geb/dotool) simpler to use than ydotool

Offline

#7 2023-04-23 16:11:51

yttrium
Member
Registered: 2017-02-19
Posts: 11

Re: Help with getting ydotool to work

I was not aware of this tool, thanks!

Offline

#8 2024-04-08 13:32:50

yttrium
Member
Registered: 2017-02-19
Posts: 11

Re: Help with getting ydotool to work

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

Board footer

Powered by FluxBB