Linux UI Automation CLI
Use xdotool, wmctrl, and xclip to automate Linux desktop UI. This is a Linux alternative to macOS Peekaboo automation features.
Setup
Install required tools:
sudo apt-get install -y xdotool xclip wmctrl xwininfo
Keyboard Input
Type text
xdotool type "Hello World"
Type with delay (ms between keys)
xdotool type --delay 50 "Hello World"
Press key
xdotool key Return
xdotool key Escape
xdotool key Tab
xdotool key BackSpace
Key combinations
xdotool key ctrl+c
xdotool key ctrl+v
xdotool key ctrl+shift+t
xdotool key alt+F4
xdotool key super
Hold and release
xdotool keydown shift
xdotool type "hello"
xdotool keyup shift
Mouse Input
Move mouse to coordinates
xdotool mousemove 500 300
Move relative
xdotool mousemove_relative 100 50
Click
xdotool click 1 # Left click
xdotool click 2 # Middle click
xdotool click 3 # Right click
Double click
xdotool click --repeat 2 --delay 50 1
Click at position
xdotool mousemove 500 300 click 1
Drag
xdotool mousemove 100 100
xdotool mousedown 1
xdotool mousemove 500 500
xdotool mouseup 1
Scroll
xdotool click 4 # Scroll up
xdotool click 5 # Scroll down
Scroll multiple times
xdotool click --repeat 5 --delay 50 5 # Scroll down 5 times
Window Management
Get active window ID
xdotool getactivewindow
Focus window by name
xdotool search --name "Firefox" windowactivate
Focus window by class
xdotool search --class "code" windowactivate
List windows
wmctrl -l
Activate window by title
wmctrl -a "Visual Studio Code"
Minimize window
xdotool getactivewindow windowminimize
Maximize window
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
Move window
xdotool getactivewindow windowmove 100 100
Resize window
xdotool getactivewindow windowsize 800 600
Close window
xdotool getactivewindow windowclose
Bring window to front
wmctrl -a "Firefox"
Clipboard
Copy text to clipboard
echo "Hello World" | xclip -selection clipboard
Paste from clipboard
xclip -selection clipboard -o
Copy file contents to clipboard
cat file.txt | xclip -selection clipboard
Copy image to clipboard
xclip -selection clipboard -t image/png -i image.png
Copy from primary selection
xclip -selection primary -o
Application Control
Launch application
xdotool exec firefox
Launch and wait for window
xdotool exec --sync firefox
Get window PID
xdotool getactivewindow getwindowpid
Kill window
xdotool getactivewindow getwindowpid | xargs kill
Combined Workflows
Open terminal and run command
xdotool key ctrl+alt+t
sleep 1
xdotool type "ls -la"
xdotool key Return
Copy selected text
xdotool key ctrl+c
sleep 0.1
xclip -selection clipboard -o
Paste text
echo "Text to paste" | xclip -selection clipboard
xdotool key ctrl+v
Switch to window and type
xdotool search --name "Slack" windowactivate
sleep 0.5
xdotool type "Hello team!"
xdotool key Return
Wait for Window
Wait for window to appear
xdotool search --sync --name "Firefox"
Wait and activate
xdotool search --sync --name "Dialog" windowactivate
Get Window Info
Window geometry
xdotool getactivewindow getwindowgeometry
Window name
xdotool getactivewindow getwindowname
All windows matching name
xdotool search --name "Code"
Screen Info
Get screen size
xdotool getdisplaygeometry
Get mouse location
xdotool getmouselocation
Notes
- Linux-only (alternative to macOS Peekaboo/keyboard maestro).
- Works with X11; for Wayland, use
ydotoolinstead. - Add delays between actions for reliability.
- Use
--syncflag to wait for windows. - Some applications may block synthetic input.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.