Where to start daemon?

I need to run ydotoold daemon from somewhere only once, preferably under my user account. I was wondering in which profile, *rc file, I should put it?
I am running GNOME.
ydotoold is installed in /usr/local/bin

Thank you for the help
-r-

You can create a systemd unit for it, and enable it with your user account. Or you can put an autostart script in

~/.config/autostart/

That last option might be quicker, I don’t know which is best. But in theory you should be able to just link it:

ln -s /usr/ocal/bin/<scriptFileName> ~/.config/autostart/<startupscript.sh>

Where:

  • <scriptFileName> is the name of the script you wish to execute
  • <startupscript.sh> is the name of the link.

Hope this helps!

Thank you,
few questions:

  • is a thing from ~/.confing/autostart/ run only once or at each shell start?
  • will it run and disconnect from a calling process ( like & in shell) (so it will be on background) ?

-r-

Indeed. I have 2 scripts that I haven’t yet bothered to convert into SystemD units there myself.

Indeed it will.

Well I have spent quite some time with this and what you were saying above is not true, at least not in my case.
The ~/.config/autostart accepts only .desktop files not a script nor executable of any kind.

in journal from systems you will find notes from systemd-xdg-autostart-generator informing you about it.

I have created systemd .service file as I though that would be the proper way, but for this specific case it doesn’t work very well, because of timing and my lack of knowledge how to specify when to start my service (daemon). I have created following .service file

[Unit]
Description=Creating virtual device for ydotool for autotyping
## make sure we only start the service after network is up
After=getty.target

[Service]
# By default 'simple' is used, see also https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
# Type=simple|forking|oneshot|dbus|notify|idle
Type=simple

User=richo
Group=users

ExecStart=/usr/local/bin/ydotoold
ExecReload=/usr/bin/kill -HUP $MAINPID
KillMode=process
TimeoutSec=180

Restart=on-failure
RestartSec=30s


[Install]
WantedBy=multi-user.target

Unfortunately this service is started too early I guess and for a while it is restarting because following error:

failed to open uinput device: Permission denied

This happens also if I create following .desktop file and place it in ~/.config/autostart

[Desktop Entry]
Name=ydotoold
GenericName=Daemon for auto typing tool yudotool
Comment=Makes possible to run ydotool
Exec=/usr/local/bin/ydotoold
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

If I run .service as root, my client program can’t connect as the daemon creates socket with incorrect permission.
srw------- 1 root root 0 Nov 25 15:23 .ydotool_socket

Currently the only feasible solution is run service as my userid and live with multiple restarts until I logs in after restart.

Why? ydotool is in the community repository.

There already is one included in the repo package:

❯ pacman -Fl ydotool | grep service
ydotool usr/lib/systemd/user/ydotool.service

More info:

– Wayland - ArchWiki

1 Like

You can place the script in your home dir. Documents perhaps. Then in autostart create a desktop file pointing to your script in the exec line.

No idea you have to ask the author of AUR ydotool-bin package

Correct as it was not working properly I decided to experiment and learn.

This is great thanks, but not in the AUR package, I will look at github, ut I was after proper way in manjaro.

This is really great, this seems to solve all the problems:

*--socket-path arg*  _<path>_
	Socket path (default: /tmp/.ydotool_socket)

*--socket-perm arg* _<perms>_
	Socket permission (default: 0600)

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.