Skip to content

Instantly share code, notes, and snippets.

@etigui
Last active July 9, 2025 14:43
Show Gist options
  • Save etigui/590f6ed9e8d720dece775de124a71080 to your computer and use it in GitHub Desktop.
Save etigui/590f6ed9e8d720dece775de124a71080 to your computer and use it in GitHub Desktop.
xdotool usage examples

xdotool usage xamples

xdotool allows you to simulate keyboard input, control mouse actions, move or resize windows, and more. It achieves this by leveraging the X11 XTEST extension along with other Xlib functions.

Get window ID by name

# List all visible window IDs matching a given name
xdotool search --onlyvisible --name "127.0.0.1:3393"
52428807
100663984

# Get a specific window ID
xdotool search --name "127.0.0.1:3393" | awk 'NR==2'
100663839

Bring a window to the front

xdotool windowactivate 100663839

Activate a window and send a keypress

xdotool windowactivate --sync 100663984 key Right

Activate a window and type text

xdotool windowactivate --sync 100663984 type "Hello World"

Ref:

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