Skip to content

Instantly share code, notes, and snippets.

@danielrosehill
Created November 25, 2025 15:43
Show Gist options
  • Select an option

  • Save danielrosehill/330230022d964c5fb44799240ed63b97 to your computer and use it in GitHub Desktop.

Select an option

Save danielrosehill/330230022d964c5fb44799240ed63b97 to your computer and use it in GitHub Desktop.
ydotoold systemd user service - Wayland input automation daemon

ydotoold systemd User Service

ydotool is a command-line tool for simulating keyboard and mouse input on Linux, working on both X11 and Wayland. Unlike xdotool, it operates at the kernel level via /dev/uinput, making it display-server agnostic.

The daemon (ydotoold) must be running for ydotool commands to work.

Service File Structure

Create the service file at ~/.config/systemd/user/ydotoold.service:

[Unit]
Description=ydotool user daemon
After=graphical-session.target
After=xdg-desktop-portal.service
PartOf=graphical-session.target

[Service]
ExecStartPre=/usr/bin/sleep 2
ExecStart=/path/to/ydotoold
ExecStartPost=/usr/bin/sleep 0.5
ExecStartPost=/usr/bin/chmod 666 /tmp/.ydotool_socket
Restart=on-failure
RestartSec=1s

[Install]
WantedBy=graphical-session.target

Key Configuration Explained

Directive Purpose
After=graphical-session.target Ensures the daemon starts after the desktop session is ready
After=xdg-desktop-portal.service Waits for XDG portal (important for Wayland)
PartOf=graphical-session.target Ties the service lifecycle to the graphical session
ExecStartPre=/usr/bin/sleep 2 Brief delay to ensure session is fully initialized
ExecStartPost=/usr/bin/chmod 666 /tmp/.ydotool_socket Makes the socket accessible to all users (required for non-root operation)
Restart=on-failure Automatically restarts if the daemon crashes
WantedBy=graphical-session.target Enables auto-start with graphical login

Installation & Enabling

  1. Create the service directory (if it doesn't exist):

    mkdir -p ~/.config/systemd/user
  2. Create the service file:

    nano ~/.config/systemd/user/ydotoold.service
    # Paste the service configuration above
  3. Adjust the ExecStart path to point to your ydotoold binary:

    # Find your ydotoold location
    which ydotoold
    # Update ExecStart= in the service file accordingly
  4. Reload systemd and enable the service:

    systemctl --user daemon-reload
    systemctl --user enable ydotoold.service
    systemctl --user start ydotoold.service
  5. Verify it's running:

    systemctl --user status ydotoold.service

Checking Service Status

# Check if enabled at boot
systemctl --user is-enabled ydotoold

# Check current status
systemctl --user status ydotoold

# View logs
journalctl --user -u ydotoold

Socket Permissions Note

The chmod 666 on the socket (/tmp/.ydotool_socket) is necessary because ydotoold typically runs as your user but other processes may need to communicate with it. Without this, you may get "permission denied" errors when running ydotool commands.

Troubleshooting

  • "ydotool: error: failed to connect to socket" - The daemon isn't running. Start it with systemctl --user start ydotoold
  • Permission errors - Ensure the chmod post-start command is in place
  • Not starting at boot - Verify graphical-session.target is reached: systemctl --user list-units --type=target

This gist was generated by Claude Code. Please validate the information for your specific environment and ydotool version.

Comments are disabled for this gist.