LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

Input

Getting Started

Which tool works depends on your display server: xclip, xsel, and xdotool are for X11, while wl-copy, wtype are for Wayland. ydotool works on both because it injects events at the kernel level (it needs the ydotoold daemon running and root or uinput access).
$ echo $XDG_SESSION_TYPE
copy

Clipboard on X11

Copy a file or command output to the clipboard, and paste it back out.
$ xclip -sel clip [file]
copy
$ uname -a | xclip -sel clip
copy
$ xclip -o -sel clip
copy
xsel does the same job with slightly different flags.
$ xsel -b < [file]
copy
$ xsel -b
copy
X11 has two clipboards: the regular one (-sel clip, pasted with Ctrl+V) and the primary selection (pasted with the middle mouse button).

Clipboard on Wayland

$ wl-copy "Hello world"
copy
$ uname -a | wl-copy
copy

Moving the Mouse

Move to an absolute screen position, or relative to the current position.
$ xdotool mousemove [x] [y]
copy
$ xdotool mousemove_relative [x] [y]
copy
$ ydotool mousemove --absolute [x] [y]
copy
$ ydotool mousemove [x] [y]
copy

Clicking

xdotool numbers buttons 1 (left), 2 (middle), 3 (right). ydotool uses button codes: 0xC0 left, 0xC1 right, 0xC2 middle.
$ xdotool click 1
copy
$ xdotool click 3
copy
$ ydotool click 0xC0
copy
$ ydotool click 0xC1
copy

Typing Text

$ xdotool type "Hello world"
copy
$ ydotool type "Hello world"
copy
$ wtype "Hello world"
copy

Pressing Keys

xdotool and wtype accept key names. ydotool uses Linux keycodes with :1 for press and :0 for release, so Escape (keycode 1) is 1:1 1:0.
$ xdotool key Escape
copy
$ xdotool key ctrl+shift+t
copy
$ wtype -k Escape
copy
$ ydotool key 1:1 1:0
copy
Find keycodes for ydotool in /usr/include/linux/input-event-codes.h, for example KEYENTER is 28 and KEYLEFTALT is 56.
Copied to clipboard
Kai