Dup Ver Goto 📝

xdotool

PT2/gui/x11/utils does not exist
To
167 lines, 375 words, 4041 chars Page 'XDoTool' does not exist.

Random Examples

Examples

List window names matching pattern

xdotool search --name "$search_string" getwindowname %@                  # or
xdotool search --name "$search_string" | xargs -n1 xdotool getwindowname

Send keys to named window (sends to):

xdotool search --name "$search_string" key key1 key2 ...

Keysyms

See XKeySyms for all. Snarfed using regex from here and /usr/include/X11/keysymdef.h. Here is a selection. Note that these syms are case sensitive.

KeysymHexDescription
Alt_L0xffe9Left alt
Alt_R0xffeaRight alt
asciicircum0x005eU+005E CIRCUMFLEX ACCENT
asciitilde0x007eU+007E TILDE
asterisk0x002aU+002A ASTERISK
at0x0040U+0040 COMMERCIAL AT
BackSpace0xff08Back space, back char
braceleft0x007bU+007B LEFT CURLY BRACKET
braceright0x007dU+007D RIGHT CURLY BRACKET
bracketleft0x005bU+005B LEFT SQUARE BRACKET
bracketright0x005dU+005D RIGHT SQUARE BRACKET
Break0xff6b
Cancel0xff69Cancel, stop, abort, exit
Caps_Lock0xffe5Caps lock
Clear0xff0b
colon0x003aU+003A COLON
comma0x002cU+002C COMMA
Control_L0xffe3Left control
Control_R0xffe4Right control
Delete0xffffDelete, rubout
Down0xff54Move down, down arrow
End0xff57EOL
Escape0xff1b
F10xffbe
...
F90xffc6
F100xffc7
F110xffc8
F120xffc9
...
F200xffd1
...
F300xffdb
...
F350xffe0
Help0xff6aHelp
Home0xff50
Hyper_L0xffedLeft hyper
Hyper_R0xffeeRight hyper
Insert0xff63Insert, insert here
KP_00xffb0
KP_10xffb1
...
KP_90xffb9
KP_Add0xffab
KP_Begin0xff9d
KP_Decimal0xffae
KP_Delete0xff9f
KP_Divide0xffaf
KP_Down0xff99
KP_End0xff9c
KP_Enter0xff8dEnter
KP_Equal0xffbdEquals
KP_F10xff91PF1, KP_A, ...
KP_F20xff92
KP_F30xff93
KP_F40xff94
KP_Home0xff95
KP_Insert0xff9e
KP_Left0xff96
KP_Multiply0xffaa
KP_Next0xff9b
KP_Page_Down0xff9b
KP_Page_Up0xff9a
KP_Prior0xff9a
KP_Right0xff98
KP_Separator0xffacSeparator, often comma
KP_Space0xff80Space
KP_Subtract0xffad
KP_Tab0xff89
KP_Up0xff97
Left0xff51Move left, left arrow
Linefeed0xff0aLinefeed, LF
Menu0xff67
Meta_L0xffe7Left meta
Meta_R0xffe8Right meta
Multi_key0xff20Multi-key character compose
Next0xff56Next
Num_Lock0xff7f
Page_Down0xff56
Page_Up0xff55
Pause0xff13Pause, hold
Prior0xff55Prior, previous
Redo0xff66Redo, again
Return0xff0dReturn, enter
Right0xff53Move right, right arrow
Scroll_Lock0xff14
Select0xff60Select, mark
semicolon0x003bU+003B SEMICOLON
Shift_L0xffe1Left shift
Shift_Lock0xffe6Shift lock
Shift_R0xffe2Right shift
slash0x002fU+002F SOLIDUS
space0x0020U+0020 SPACE
Super_L0xffebLeft super
Super_R0xffecRight super
Tab0xff09
underscore0x005fU+005F LOW LINE
Undo0xff65
Up0xff52Move up, up arrow

Scripts

Example python script using curses and subprocess to send keypresses to named window using xdotool. (Note also that there is an xdotool package python-libxdo, installable via package python3-xdo under Ubuntu 24.04, for python rather than using subprocess.run).

#!/usr/bin/env python3

import curses
import subprocess
import sys
args = sys.argv[1:]
try:
  name = args[0]
except Exception:
  print(f"{args[0]} <window search pattern>")
  exit(1)

def sendkey(x):
  subprocess.run(["xdotool","search","--name",name,"key",x])

def main(stdscr):
  curses.noecho()
  stdscr.addstr(f"Search for {name}\nPress left, right, up, down, or a character\n")
  stdscr.refresh()
  try:
    while True:
      c = stdscr.getch()
      k = chr(c)
      if k.upper() in "ABCDEFGHIJLKMNOPQRSTYVWXYZ0123456789":
        sendkey(k)
      elif k == " ":
        sendkey("space")
      elif c == curses.KEY_LEFT:
        sendkey("Left")
      elif c == curses.KEY_RIGHT:
        sendkey("Right")
      elif c == curses.KEY_UP:
        sendkey("Up")
      elif c == curses.KEY_DOWN:
        sendkey("Down")
  except KeyboardInterrupt:
    return

if __name__ == "__main__":
  curses.wrapper(main)