Skip to content

Instantly share code, notes, and snippets.

@CodeZombie
Last active October 27, 2025 22:45
Show Gist options
  • Select an option

  • Save CodeZombie/c7f0e37dd67d8cc0e78064a95f56a5f4 to your computer and use it in GitHub Desktop.

Select an option

Save CodeZombie/c7f0e37dd67d8cc0e78064a95f56a5f4 to your computer and use it in GitHub Desktop.
pastetype
#!/bin/bash
# 1. Start ydotoold in the background
# The '&' runs the command as a background job
ydotoold &
# 2. Save the Process ID (PID) of the background process
# '$!' is a special variable that holds the PID of the last backgrounded process
YDOTOOLD_PID=$!
# 3. Wait for ydotoold to initialize
# This is important! If ydotool runs too fast, it may fail to connect.
# You might need to adjust this
sleep 0.5
# 4. type out the contents of the clipboard
ydotool type --key-delay=1 --key-hold=1 "$(wl-paste)"
# 5. Stop the ydotoold daemon now that typing is finished
kill $YDOTOOLD_PID
echo "Script finished."
@CodeZombie
Copy link
Author

CodeZombie commented Oct 27, 2025

You should be careful with this, as "pasting" a huge amount of text will take a fairly long time, even with key-delay and key-hold set to 1. Once it's started, there isn't really a way to halt it.

While ydotool is typing, it wont care which window you're focused on, and will continue typing text even if you switch to a sensitive window, so be cautious!

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