Skip to content

Instantly share code, notes, and snippets.

@retspen
Created February 18, 2026 11:10
Show Gist options
  • Select an option

  • Save retspen/5b57a24e2063c155fb8db6bbc154a0c4 to your computer and use it in GitHub Desktop.

Select an option

Save retspen/5b57a24e2063c155fb8db6bbc154a0c4 to your computer and use it in GitHub Desktop.
dotool wrapper for ydotool – reliable paste with Non-US layouts (Wayland)
#!/usr/bin/env bash
set -euo pipefail
# Copy from pipe
wl-copy
# Get text from buffer
text="$(wl-paste)"
# Remove prefix "type " if it exist
if [[ "$text" == type\ * ]]; then
text="${text#type }"
fi
# Put back to clipboard
printf '%s' "$text" | wl-copy
# Shift+Insert
ydotool key 29:1 42:1 47:1 47:0 42:0 29:0
[Unit]
Description=Starts ydotoold service (user)
After=graphical-session.target
[Service]
Type=simple
Restart=on-failure
RestartSec=1
ExecStart=/usr/bin/ydotoold
ExecReload=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=graphical-session.target
@retspen
Copy link
Author

retspen commented Feb 18, 2026

This wrapper avoids layout-dependent issues when using ydotool type under Wayland with Non-US keyboard layouts.

Instead of injecting characters directly, it copies stdin to the clipboard and pastes it using Shift+Insert, which is layout-agnostic and reliable.


Installation

Add user to input group and setup permission:

sudo usermod -aG input $USER
echo 'KERNEL=="uinput", MODE="0660", GROUP="input"' | sudo tee /etc/udev/rules.d/99-uinput.rules

Download and install the wrapper:

sudo wget https://gist.githubusercontent.com/retspen/5b57a24e2063c155fb8db6bbc154a0c4/raw/b914c303c00d039e889d4f643c571fe47463a221/dotool -O /usr/bin/dotool
sudo chmod +x /usr/bin/dotool

Ensure the systemd user directory exists:

mkdir -p $HOME/.config/systemd/user

Download service file:

wget https://gist.githubusercontent.com/retspen/5b57a24e2063c155fb8db6bbc154a0c4/raw/b914c303c00d039e889d4f643c571fe47463a221/ydotool.service -O $HOME/.config/systemd/user/ydotool.service

Reload and enable the service:

systemctl --user daemon-reload
systemctl --user enable --now ydotool.service

Reboot and ensure ydotoold starts automatically after the graphical session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment