1XDOTOOL(1)                                                          XDOTOOL(1)
2
3
4

NAME

6       xdotool - command-line X11 automation tool
7

SYNOPSIS

9       xdotool cmd args...
10
11       Notation: Some documentation uses [window] to denote an optional window
12       argument. This case means that the argument, if not present, will
13       default to "%1". See "WINDOW STACK" for what "%1" means.
14

DESCRIPTION

16       xdotool lets you programmatically (or manually) simulate keyboard input
17       and mouse activity, move and resize windows, etc. It does this using
18       X11's XTEST extension and other Xlib functions.
19
20       There is some support for Extended Window Manager Hints (aka EWMH or
21       NetWM).  See the "EXTENDED WINDOW MANAGER HINTS" section for more
22       information.
23

KEYBOARD COMMANDS

25       key [options] keystroke [keystroke ...]
26           Options:
27
28           --window window
29               Send keystrokes to a specific window id. You can use "WINDOW
30               STACK" references like "%1" and "%@" here. If there is a window
31               stack, then "%1" is the default, otherwise the current window
32               is used.
33
34               See also: "SENDEVENT NOTES" and "WINDOW STACK"
35
36           --clearmodifiers
37               Clear modifiers before sending keystrokes. See CLEARMODIFIERS
38               below.
39
40           --delay milliseconds
41               Delay between keystrokes. Default is 12ms.
42
43           Type a given keystroke. Examples being "alt+r", "Control_L+J",
44           "ctrl+alt+n", "BackSpace".
45
46           Generally, any valid X Keysym string will work. Multiple keys are
47           separated by '+'. Aliases exist for "alt", "ctrl", "shift",
48           "super", and "meta" which all map to Foo_L, such as Alt_L and
49           Control_L, etc.
50
51           In cases where your keyboard doesn't actually have the key you want
52           to type, xdotool will automatically find an unused keycode and use
53           that to type the key.
54
55           With respect to "COMMAND CHAINING", this command consumes the
56           remainder of the arguments or until a new xdotool command is seen,
57           because no xdotool commands are valid keystrokes.
58
59           Example: Send the keystroke "F2"
60            xdotool key F2
61
62           Example: Send 'a' with an accent over it (not on English keyboards,
63           but still works with xdotool)
64            xdotool key Aacute
65
66           Example: Send ctrl+l and then BackSpace as separate keystrokes:
67            xdotool key ctrl+l BackSpace
68
69           Example: Send ctrl+c to all windows matching title 'gdb' (See
70           "COMMAND CHAINING")
71            xdotool search --name gdb key ctrl+c
72
73       keydown [options] keystroke
74           Same as above, except only keydown (press) events are sent.
75
76       keyup keystroke
77           Same as above, except only keyup (release) events are sent.
78
79       type [options] something to type
80           Options:
81
82           --window windowid
83               Send keystrokes to a specific window id. See "SENDEVENT NOTES"
84               below. The default, if no window is given, depends on the
85               window stack. If the window stack is empty the current window
86               is typed at using XTEST. Otherwise, the default is "%1" (see
87               "WINDOW STACK").
88
89           --delay milliseconds
90               Delay between keystrokes. Default is 12ms.
91
92           --clearmodifiers
93               Clear modifiers before sending keystrokes. See CLEARMODIFIERS
94               below.
95
96           Types as if you had typed it. Supports newlines and tabs (ASCII
97           newline and tab). Each keystroke is separated by a delay given by
98           the --delay option.
99
100           With respect to "COMMAND CHAINING", this command consumes the
101           remainder of the arguments and types them. That is, no commands can
102           chain after 'type'.
103
104           Example: to type 'Hello world!' you would do:
105            xdotool type 'Hello world!'
106

MOUSE COMMANDS

108       mousemove [options] x y OR 'restore'
109           Move the mouse to the specific X and Y coordinates on the screen.
110
111           You can move the mouse to the previous location if you specify
112           'restore' instead of an X and Y coordinate. Restoring only works if
113           you have moved previously in this same command invocation. Further,
114           it does not work with the --window option.
115
116           For example, to click the top-left corner of the screen and move
117           the mouse to the original position before you moved it, use this:
118            xdotool mousemove 0 0 click 1 mousemove restore
119
120           --window WINDOW
121               Specify a window to move relative to. Coordinates 0,0 are at
122               the top left of the window you choose.
123
124               "WINDOW STACK" references are valid here, such as %1 and %@.
125               Though, using %@ probably doesn't make sense.
126
127           --screen SCREEN
128               Move the mouse to the specified screen to move to. This is only
129               useful if you have multiple screens and ARE NOT using Xinerama.
130
131               The default is the current screen. If you specify --window, the
132               --screen flag is ignored.
133
134           --polar
135               Use polar coordinates. This makes 'x' an angle (in degrees,
136               0-360, etc) and 'y' the distance.
137
138               Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 =
139               right, 180 = down, 270 = left.
140
141               The origin defaults to the center of the current screen. If you
142               specify a --window, then the origin is the center of that
143               window.
144
145           --clearmodifiers
146               See CLEARMODIFIERS
147
148           --sync
149               After sending the mouse move request, wait until the mouse is
150               actually moved. If no movement is necessary, we will not wait.
151               This is useful for scripts that depend on actions being
152               completed before moving on.
153
154               Note: We wait until the mouse moves at all, not necessarily
155               that it actually reaches your intended destination. Some
156               applications lock the mouse cursor to certain regions of the
157               screen, so waiting for any movement is better in the general
158               case than waiting for a specific target.
159
160       mousemove_relative [options] x y
161           Move the mouse x,y pixels relative to the current position of the
162           mouse cursor.
163
164           --polar
165               Use polar coordinates. This makes 'x' an angle (in degrees,
166               0-360, etc) and 'y' the distance.
167
168               Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 =
169               right, 180 = down, 270 = left.
170
171           --sync
172               After sending the mouse move request, wait until the mouse is
173               actually moved. If no movement is necessary, we will not wait.
174               This is useful for scripts that depend on actions being
175               completed before moving on.
176
177               Note that we wait until the mouse moves at all, not necessarily
178               that it actually reaches your intended destination. Some
179               applications lock the mouse cursor to certain regions of the
180               screen, so waiting for any movement is better in the general
181               case than waiting for a specific target.
182
183           --clearmodifiers
184               See CLEARMODIFIERS
185
186       click [options] button
187           Send a click, that is, a mousedown followed by mouseup for the
188           given button with a short delay between the two (currently 12ms).
189
190           Buttons generally map this way: Left mouse is 1, middle is 2, right
191           is 3, wheel up is 4, wheel down is 5.
192
193           --clearmodifiers
194               Clear modifiers before clicking. See CLEARMODIFIERS below.
195
196           --repeat REPEAT
197               Specify how many times to click. Default is 1. For a double-
198               click, use '--repeat 2'
199
200           --delay MILLISECONDS
201               Specify how long, in milliseconds, to delay between clicks.
202               This option is not used if the --repeat flag is set to 1
203               (default).
204
205           --window WINDOW
206               Specify a window to send a click to. See "SENDEVENT NOTES"
207               below for caveats. Uses the current mouse position when
208               generating the event.
209
210               The default, if no window is given, depends on the window
211               stack. If the window stack is empty the current window is typed
212               at using XTEST. Otherwise, the default is "%1" (see "WINDOW
213               STACK").
214
215       mousedown [options] button
216           Same as click, except only a mouse down is sent.
217
218       mouseup [options] button
219           Same as click, except only a mouse up is sent.
220
221       getmouselocation [--shell]
222           Outputs the x, y, screen, and window id of the mouse cursor. Screen
223           numbers will be nonzero if you have multiple monitors and are not
224           using Xinerama.
225
226           --shell
227               This makes getmouselocation output shell data you can eval.
228               Example:
229
230                % xdotool getmouselocation --shell
231                X=880
232                Y=443
233                SCREEN=0
234                WINDOW=16777250
235
236                % eval $(xdotool getmouselocation --shell)
237                % echo $X,$Y
238                714,324
239
240       behave_screen_edge [options] where command ...
241           Bind an action to events when the mouse hits the screen edge or
242           corner.
243
244           Options are:
245
246           --delay MILLISECONDS
247               Delay in milliseconds before running the command. This allows
248               you to require a given edge or corner to be held for a short
249               period before your command will run. If you leave the edge or
250               corner before the delay expires then the time will reset.
251
252           --quiesce MILLISECONDS
253               Delay in milliseconds before the next command will run. This
254               helps prevent accidentally running your command extra times;
255               especially useful if you have a very short --delay (like the
256               default of 0).
257
258           Event timeline
259
260            * Mouse hits an edge or corner.
261            * If delay is nonzero, the mouse must stay in this edge or corner until delay time expires.
262            * If still in the edge/corner, trigger.
263            * If quiesce is nonzero, then there is a cool-down period where the next
264              trigger cannot occur
265
266           Valid 'where' values are:
267
268           left
269           top-left
270           top
271           top-right
272           right
273           bottom-left
274           bottom
275           bottom-right
276
277           Examples:
278            # Activate google-chrome when you move the mouse to the bottom-
279           left corner:
280            xdotool behave_screen_edge bottom-left \
281              search --class google-chrome windowactivate
282
283            # Go to the next workspace (right). Known to work in GNOME (metacity and compiz)
284            xdotool behave_screen_edge --delay 500 bottom-right key XF86Forward
285
286            # Activate firefox and do a web search in a new tab for text in your clipboard
287            xdotool behave_screen_edge --delay 1000 top-left \
288                search --classname Navigator \
289                windowactivate --sync key --delay 250 ctrl+t ctrl+k ctrl+v Return
290

WINDOW COMMANDS

292       search [options] pattern
293           Search for windows with titles, names, or classes with a regular
294           expression pattern. The output is line-delimited list of X window
295           identifiers. If you are using "COMMAND CHAINING", the search
296           command will only write window ids to stdout if it is the last (or
297           only) command in the chain; otherwise, it is silent.
298
299           The result is saved to the window stack for future chained
300           commands. See "WINDOW STACK" and "COMMAND CHAINING" for details.
301
302           The default options are "--name --class --classname" (unless you
303           specify one one or more of --name --class or --classname).
304
305           The options available are:
306
307           --class
308               Match against the window class.
309
310           --classname
311               Match against the window classname.
312
313           --maxdepth N
314               Set recursion/child search depth. Default is -1, meaning
315               infinite. 0 means no depth, only root windows will be searched.
316               If you only want toplevel windows, set maxdepth of 1 (or 2,
317               depending on how your window manager does decorations).
318
319           --name
320               Match against the window name. This is the same string that is
321               displayed in the window titlebar.
322
323           --onlyvisible
324               Show only visible windows in the results. This means ones with
325               map state IsViewable.
326
327           --pid PID
328               Match windows that belong to a specific process id. This may
329               not work for some X applications that do not set this metadata
330               on its windows.
331
332           --screen N
333               Select windows only on a specific screen. Default is to search
334               all screens. Only meaningful if you have multiple displays and
335               are not using Xinerama.
336
337           --desktop N
338               Only match windows on a certain desktop. 'N' is a number. The
339               default is to search all desktops.
340
341           --limit N
342               Stop searching after finding N matching windows. Specifying a
343               limit will help speed up your search if you only want a few
344               results.
345
346               The default is no search limit (which is equivalent to '--limit
347               0')
348
349           --title
350               DEPRECATED. See --name.
351
352           --all
353               Require that all conditions be met. For example:
354
355                xdotool search --all --pid 1424 --name "Hello World"
356
357               This will match only windows that have "Hello World" as a name
358               and are owned by pid 1424.
359
360           --any
361               Match windows that match any condition (logically, 'or'). This
362               is on by default. For example:
363
364                xdotool search --any --pid 1424 --name "Hello World"
365
366               This will match any windows owned by pid 1424 or windows with
367               name "Hello World"
368
369           --sync
370               Block until there are results. This is useful when you are
371               launching an application and want to wait until the application
372               window is visible.  For example:
373
374                google-chrome &
375                xdotool search --sync --onlyvisible --class "google-chrome"
376
377       selectwindow
378           Get the window id (for a client) by clicking on it. Useful for
379           having scripts query you humans for what window to act on. For
380           example, killing a window by clicking on it:
381
382            xdotool selectwindow windowkill
383
384       behave window action command ...
385           Bind an action to an event on a window. This lets you run
386           additional xdotool commands whenever a matched event occurs.
387
388           The command run as a result of the behavior is run with %1 being
389           the window that was acted upon. Examples follow after the event
390           list.
391
392           The following are valid events:
393
394           mouse-enter
395               Fires when the mouse enters a window. This is similar to 'mouse
396               over' events in javascript, if that helps.
397
398           mouse-leave
399               Fires when the mouse leaves a window. This is the opposite of
400               'mouse-enter'
401
402           mouse-click
403               Fires when the mouse is clicked. Specifically, when the mouse
404               button is released.
405
406           focus
407               Fires when the window gets input focus.
408
409           blur
410               Fires when the window loses focus.
411
412           Examples:
413
414            # Print the cursor location whenever the mouse enters a currently-visible
415            # window:
416            xdotool search --onlyvisible . behave %@ mouse-enter getmouselocation
417
418            # Print the window title and pid whenever an xterm gets focus
419            xdotool search --class xterm behave %@ focus getwindowname getwindowpid
420
421            # Emulate focus-follows-mouse
422            xdotool search . behave %@ mouse-enter windowfocus
423
424       getwindowpid [window]
425           Output the PID owning a given window. This requires effort from the
426           application owning a window and may not work for all windows. This
427           uses _NET_WM_PID property of the window. See "EXTENDED WINDOW
428           MANAGER HINTS" below for more information.
429
430           If no window is given, the default is '%1'. If no windows are on
431           the stack, then this is an error. See "WINDOW STACK" for more
432           details.
433
434           Example: Find the PID for all xterms:
435            xdotool search --class xterm getwindowpid %@
436
437       getwindowname [window]
438           Output the name of a given window, also known as the title. This is
439           the text displayed in the window's titlebar by your window manager.
440
441           If no window is given, the default is '%1'. If no windows are on
442           the stack, then this is an error. See "WINDOW STACK" for more
443           details.
444
445       getwindowgeometry [options] [window]
446           Output the geometry (location and position) of a window. The values
447           include: x, y, width, height, and screen number.
448
449           --shell
450               Output values suitable for 'eval' in a shell.
451
452       getwindowfocus [-f]
453           Prints the window id of the currently focused window. Saves the
454           result to the window stack. See "WINDOW STACK" for more details.
455
456           If the current window has no WM_CLASS property, we assume it is not
457           a normal top-level window and traverse up the parents until we find
458           a window with a WM_CLASS set and return that window id.
459
460           If you really want the window currently having focus and don't care
461           if it has a WM_CLASS setting, then use 'getwindowfocus -f'
462
463       windowsize [options] [window] width height
464           Set the window size of the given window. If no window is given, %1
465           is the default.  See "WINDOW STACK" and "COMMAND CHAINING" for more
466           details.
467
468           Percentages are valid for width and height. They are relative to
469           the geometry of the screen the window is on. For example, to make a
470           window the full width of the screen, but half height:
471
472            xdotool windowsize I<window> 100% 50%
473
474           Percentages are valid with --usehints and still mean pixel-width
475           relative to the screen size.
476
477           The options available are:
478
479           --usehints
480               Use window sizing hints (when available) to set width and
481               height.  This is useful on terminals for setting the size based
482               on row/column of text rather than pixels.
483
484           --sync
485               After sending the window size request, wait until the window is
486               actually resized. If no change is necessary, we will not wait.
487               This is useful for scripts that depend on actions being
488               completed before moving on.
489
490               Note: Because many window managers may ignore or alter the
491               original resize request, we will wait until the size changes
492               from its original size, not necessary to the requested size.
493
494           Example: To set a terminal to be 80x24 characters, you would use:
495            xdotool windowsize --usehints some_windowid 80 24
496
497       windowmove [options] [window] x y
498           Move the window to the given position. If no window is given, %1 is
499           the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
500           details.
501
502           If the given x coordinate is literally 'x', then the window's
503           current x position will be unchanged. The same applies for 'y'.
504
505           Examples:
506
507            xdotool getactivewindow windowmove 100 100    # Moves to 100,100
508            xdotool getactivewindow windowmove x 100      # Moves to x,100
509            xdotool getactivewindow windowmove 100 y      # Moves to 100,y
510            xdotool getactivewindow windowmove 100 y      # Moves to 100,y
511
512           Percentages are valid for width and height. They are relative to
513           the geometry of the screen the window is on. For example, to make a
514           window the full width of the screen, but half height:
515
516            xdotool windowmove I<window> 100% 50%
517
518           --sync
519               After sending the window move request, wait until the window is
520               actually moved. If no movement is necessary, we will not wait.
521               This is useful for scripts that depend on actions being
522               completed before moving on.
523
524           --relative
525               Make movement relative to the current window position.
526
527       windowfocus [options] [window]
528           Focus a window. If no window is given, %1 is the default. See
529           "WINDOW STACK" and "COMMAND CHAINING" for more details.
530
531           Uses XSetInputFocus which may be ignored by some window managers or
532           programs.
533
534           --sync
535               After sending the window focus request, wait until the window
536               is actually focused. This is useful for scripts that depend on
537               actions being completed before moving on.
538
539       windowmap [options] [window]
540           Map a window. In X11 terminology, mapping a window means making it
541           visible on the screen. If no window is given, %1 is the default.
542           See "WINDOW STACK" and "COMMAND CHAINING" for more details.
543
544           --sync
545               After requesting the window map, wait until the window is
546               actually mapped (visible). This is useful for scripts that
547               depend on actions being completed before moving on.
548
549       windowminimize [options] [window]
550           Minimize a window. In X11 terminology, this is called 'iconify.'
551           If no window is given, %1 is the default. See "WINDOW STACK" and
552           "COMMAND CHAINING" for more details.
553
554           --sync
555               After requesting the window minimize, wait until the window is
556               actually minimized. This is useful for scripts that depend on
557               actions being completed before moving on.
558
559       windowraise [window_id=%1]
560           Raise the window to the top of the stack. This may not work on all
561           window managers. If no window is given, %1 is the default. See
562           "WINDOW STACK" and "COMMAND CHAINING" for more details.
563
564       windowreparent [source_window] destination_window
565           Reparent a window. This moves the source_window to be a child
566           window of destination_window. If no source is given, %1 is the
567           default.  "WINDOW STACK" window references (like %1) are valid for
568           both source_window and destination_window See "WINDOW STACK" and
569           "COMMAND CHAINING" for more details.
570
571       windowclose [window]
572           Close a window. This action will destroy the window, but will not
573           try to kill the client controlling it. If no window is given, %1 is
574           the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
575           details.
576
577       windowkill [window]
578           Kill a window. This action will destroy the window and kill the
579           client controlling it. If no window is given, %1 is the default.
580           See WINDOW STACK and "COMMAND CHAINING" for more details.
581
582       windowunmap [options] [window_id=%1]
583           Unmap a window, making it no longer appear on your screen. If no
584           window is given, %1 is the default. See "WINDOW STACK" and "COMMAND
585           CHAINING" for more details.
586
587           --sync
588               After requesting the window unmap, wait until the window is
589               actually unmapped (hidden). This is useful for scripts that
590               depend on actions being completed before moving on.
591
592       set_window [options] [windowid=%1]
593           Set properties about a window. If no window is given, %1 is the
594           default. See "WINDOW STACK" and "COMMAND CHAINING" for more
595           details.
596
597           Options:
598
599           --name newname
600               Set window WM_NAME (the window title, usually)
601
602           --icon-name newiconname
603               Set window WM_ICON_NAME (the window title when minimized,
604               usually)
605
606           --role newrole
607               Set window WM_WINDOW_ROLE
608
609           --classname newclassname
610               Set window class name (not to be confused with window class)
611
612           --class newclass
613               Set window class (not to be confused with window class name)
614
615           --urgency value
616               Set window urgency hint. If the value is 1, the window will be
617               marked urgent, and the window manager will somehow highlight it
618               for the user's attention.  If the value is 0, the window will
619               be marked non-urgent.
620
621           --overrideredirect value
622               Set window's override_redirect value. This value is a hint to
623               the window manager for whether or not it should be managed. If
624               the redirect value is 0, then the window manager will draw
625               borders and treat this window normally. If the value is 1, the
626               window manager will ignore this window.
627
628               If you change this value, your window manager may not notice
629               the change until the window is mapped again, so you may want to
630               issue 'windowunmap' and 'windowmap' to make the window manager
631               take note.
632

DESKTOP AND WINDOW COMMANDS

634       These commands follow the EWMH standard. See the section "EXTENDED
635       WINDOW MANAGER HINTS" for more information.
636
637       windowactivate [options] [window]
638           Activate the window. This command is different from windowfocus: if
639           the window is on another desktop, we will switch to that desktop.
640           It also uses a different method for bringing the window up. I
641           recommend trying this command before using windowfocus, as it will
642           work on more window managers.
643
644           If no window is given, %1 is the default. See "WINDOW STACK" and
645           "COMMAND CHAINING" for more details.
646
647           --sync
648               After sending the window activation, wait until the window is
649               actually activated. This is useful for scripts that depend on
650               actions being completed before moving on.
651
652       getactivewindow
653           Output the current active window. This command is often more
654           reliable than getwindowfocus. The result is saved to the window
655           stack. See "WINDOW STACK" for more details.
656
657       set_num_desktops number
658           Changes the number of desktops or workspaces.
659
660       get_num_desktops
661           Output the current number of desktops.
662
663       get_desktop_viewport [--shell]
664           Report the current viewport's position. If --shell is given, the
665           output is friendly to shell eval.
666
667           Viewports are sometimes used instead of 'virtual desktops' on some
668           window managers. A viewport is simply a view on a very large
669           desktop area.
670
671       set_desktop_viewport x y
672           Move the viewport to the given position. Not all requests will be
673           obeyed - some windowmangers only obey requests that align to
674           workspace boundaries, such as the screen size.
675
676           For example, if your screen is 1280x800, you can move to the 2nd
677           workspace by doing:
678            xdotool set_desktop_viewport 1280 0
679
680       set_desktop [options] desktop_number
681           Change the current view to the specified desktop.
682
683           --relative
684               Use relative movements instead of absolute. This lets you move
685               relative to the current desktop.
686
687       get_desktop
688           Output the current desktop in view.
689
690       set_desktop_for_window [window] desktop_number
691           Move a window to a different desktop. If no window is given, %1 is
692           the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
693           details.
694
695       get_desktop_for_window [window]
696           Output the desktop currently containing the given window. Move a
697           window to a different desktop. If no window is given, %1 is the
698           default. See WINDOW STACK and "COMMAND CHAINING" for more details.
699

MISCELLANEOUS COMMANDS

701       exec [options] command [...]
702           Execute a program. This is often useful when combined with
703           behave_screen_edge to do things like locking your screen.
704
705           Options:
706
707           --sync
708               Block until the child process exits. The child process exit
709               status is then passed to the parent process (xdotool) which
710               copies it.
711
712           Examples:
713            # Lock the screen when the mouse sits in the top-right corner
714            xdotool behave_screen_edge --delay 1000 top-right \
715              exec gnome-screensaver-command --lock
716            # Substitute 'xscreensaver-command -lock' if you use that program.
717
718            # The following will fail to move the mouse because we use '--sync' and
719            # /bin/false exits nonzero:
720            xdotool exec --sync /bin/false mousemove 0 0
721
722            # This succeeds, though, since we do not use --sync on the exec command.
723            xdotool exec /bin/false mousemove 0 0
724
725       sleep seconds
726           Sleep for a specified period. Fractions of seconds (like 1.3, or
727           0.4) are valid, here.
728

SCRIPTS

730       xdotool can read a list of commands via stdin or a file if you want. A
731       script will fail when any command fails.
732
733       Truthfully, 'script' mode isn't fully fleshed out and may fall below
734       your expectations. If you have suggestions, please email the list or
735       file a bug (See CONTACT).
736
737       Scripts can use positional arguments (Represented by $1, $2, ...) and
738       environment variables (like $HOME or $WINDOWID). Quoting arguments
739       should work as expected.
740
741       Scripts are processed for parameter and environment variable expansion
742       and then run as if you had invoked xdotool with the entire script on
743       one line (using COMMAND CHAINING).
744
745       •   Read commands from a file:
746
747            xdotool filename
748
749       •   Read commands from stdin:
750
751            xdotool -
752
753       •   Read commands from a redirected file
754
755            xdotool - < myfile
756
757       You can also write scripts that only execute xdotool. Example:
758
759        #!/usr/local/bin/xdotool
760        search --onlyvisible --classname $1
761
762        windowsize %@ $2 $3
763        windowraise %@
764
765        windowmove %1 0 0
766        windowmove %2 $2 0
767        windowmove %3 0 $3
768        windowmove %4 $2 $3
769
770       This script will take all windows matched by the classname query given
771       by arg1 ($1) and sizes/moves them into a 2x2 grid with windows sized by
772       the 2nd and 3rd parameters.
773
774       Here's an example usage:
775
776        % ./myscript xterm 600 400
777
778       Running it like this will take 4 visible xterms, raise them, and move
779       them into a 2x2 tile grid with each window 600x400 pixels in size.
780

CLEARMODIFIERS

782       Any command taking the --clearmodifiers flag will attempt to clear any
783       active input modifiers during the command and restore them afterwards.
784
785       For example, if you were to run this command:
786        xdotool key a
787
788       The result would be 'a' or 'A' depending on whether or not you were
789       holding the shift key on your keyboard. Often it is undesirable to have
790       any modifiers active, so you can tell xdotool to clear any active
791       modifiers.
792
793       The order of operations if you hold shift while running 'xdotool key
794       --clearmodifiers a' is this:
795
796       1. Query for all active modifiers (finds shift, in this case)
797       2. Try to clear shift by sending 'key up' for the shift key
798       3. Runs normal 'xdotool key a'
799       4. Restore shift key by sending 'key down' for shift
800
801       The --clearmodifiers flag can currently clear of the following:
802
803       •   any key in your active keymap that has a modifier associated with
804           it.  (See xmodmap(1)'s 'xmodmap -pm' output)
805
806       •   mouse buttons (1, 2, 3, 4, and 5)
807
808       •   caps lock
809

SENDEVENT NOTES

811       If you are trying to send key input to a specific window, and it does
812       not appear to be working, then it's likely your application is ignoring
813       the events xdotool is generating. This is fairly common.
814
815       Sending keystrokes to a specific window uses a different API than
816       simply typing to the active window. If you specify 'xdotool type
817       --window 12345 hello' xdotool will generate key events and send them
818       directly to window 12345.  However, X11 servers will set a special flag
819       on all events generated in this way (see XEvent.xany.send_event in
820       X11's manual). Many programs observe this flag and reject these events.
821
822       It is important to note that for key and mouse events, we only use
823       XSendEvent when a specific window is targeted. Otherwise, we use XTEST.
824
825       Some programs can be configured to accept events even if they are
826       generated by xdotool. Seek the documentation of your application for
827       help.
828
829       Specific application notes (from the author's testing): * Firefox 3
830       seems to ignore all input when it does not have focus.  * xterm can be
831       configured while running with ctrl+leftclick, 'Allow SendEvents' *
832       gnome-terminal appears to accept generated input by default.
833

WINDOW STACK

835       Certain commands (search, getactivewindow, getwindowfocus) will find
836       windows for you. These results generally printed to stdout, but they
837       are also saved to memory for future use during the lifetime of the
838       xdotool process. See "COMMAND CHAINING" for more information.
839
840       The only modifications support for the window stack are to replace it.
841       That is, two of two sequential searches, only the last one's results
842       will be the window stack.
843

COMMAND CHAINING

845       xdotool supports running multiple commands on a single invocation.
846       Generally, you'll start with a search command (see "WINDOW STACK") and
847       then perform a set of actions on those results.
848
849       To query the window stack, you can use special notation "%N" where N is
850       a number or the '@' symbol. If %N is given, the Nth window will be
851       selected from the window stack. Generally you will only want the first
852       window or all windows.  Note that the order of windows in the window
853       stack corresponds to the window stacking order, i.e. the bottom-most
854       window will be reported first (see XQueryTree(3)). Thus the order of
855       the windows in the window stack may not be consistent across
856       invocations.
857
858       The notation described above is used as the "window" argument for any
859       given command.
860
861       For example, to resize all xterms to 80x24:
862
863        xdotool search --class xterm -- windowsize --usehints %@ 80 24
864
865       Resize move the current window:
866
867        xdotool getactivewindow windowmove 0 0
868
869       In all cases, the default window argument, if omitted, will default to
870       "%1". It is obviously an error if you omit the window argument and the
871       window stack is empty. If you try to use the window stack and it is
872       empty, it is also an error.
873
874       To activate the first firefox window found:
875
876        xdotool search --class firefox windowactivate
877
878       These would error:
879
880        xdotool windowactivate
881        xdotool windowactivate %1
882        xdotool windowactivate %@
883
884       When xdotool exits, the current window stack is lost.
885
886       Additionally, commands that modify the "WINDOW STACK" will not print
887       the results if they are not the last command. For example:
888
889        # Output the active window:
890        % xdotool getactivewindow
891        20971533
892
893        # Output the pid of the active window, but not the active window id:
894        % xdotool getactivewindow getwindowpid
895        4686
896

EXTENDED WINDOW MANAGER HINTS

898       The following pieces of the EWMH standard are supported:
899
900       _NET_SUPPORTED
901           Asks the window manager what is supported
902
903       _NET_CURRENT_DESKTOP
904           Query and set the current desktop. Support for this enables these
905           commands: "set_desktop", "get_desktop".
906
907       _NET_WM_DESKTOP
908           Query and set what desktop a window is living in. Support for this
909           enables these commands: "set_desktop_for_window",
910           "get_desktop_for_window".
911
912       _NET_ACTIVE_WINDOW
913           Allows you to query and set the active window by asking the window
914           manager to bring it forward. Support for this enables these
915           commands: "windowactivate", "getactivewindow".
916
917       _NET_WM_PID
918           This feature is application dependent, not window-manager
919           dependent. Query the PID owning a given window. Support for this
920           enables these commands: "getwindowpid".
921

SUPPORTED FEATURES

923       xdotool (and libxdo) will try to function under all circumstances.
924       However, there may be some cases where functionality is not provided by
925       your X server or by your window manager. In these cases, xdotool will
926       try to detect and tell you if an action requires a feature not
927       currently supported by your system.
928
929       For window-manager specific features, see "EXTENDED WINDOW MANAGER
930       HINTS".
931
932       XTEST
933           If your X server does not support XTEST, then some typing and mouse
934           movement features may not work. Specifically, typing and mouse
935           actions that act on the "current window" (window 0 in libxdo) are
936           unlikely to work.
937
938           In most cases, XTEST is a feature you can enable on your X server
939           if it is not enabled by default.
940
941           You can see the list of supported X extensions by typing 'xdpyinfo'
942           and looking the text 'number of extensions: ...'
943

BUGS

945       Typing unusual symbols under non-us keybindings is known to
946       occasionally send the wrong character.
947

SEE ALSO

949       xprop(1), xwininfo(1),
950
951       Project site: <http://www.semicomplete.com/projects/xdotool>
952
953       Source code and Issues: <https://github.com/jordansissel/xdotool>
954
955       EWMH specification:
956       <http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html>
957

CONTACT

959       Please send questions to xdotool-users@googlegroups.com. File bugs and
960       feature requests at the following URL:
961
962       <https://github.com/jordansissel/xdotool/issues>
963
964       Alternately, if you prefer email, feel free to file bugs by emailing
965       the list.  What works for you :)
966

AUTHOR

968       xdotool was written by Jordan Sissel.
969
970       This manual page was written originally by Daniel Kahn Gillmor
971       <dkg@fifthhorseman.net> for the Debian project (but may be used by
972       others). It is maintained by Jordan Sissel.
973
974       Patches, ideas, and other contributions by many, nice folks. See the
975       CHANGELIST file for who provided what.
976
977
978
979                                  2022-01-22                        XDOTOOL(1)
Impressum