Some Mouse & Window Controls | |
xdotool type " " | |
xdotool key type " " | (alternate type) |
xdotool click "1" | (left click) |
xdotool click "2" | (middle click) |
xdotool click "3" | (right click) |
xdotool mousedown "1" | (left button held down) |
xdotool mousedown "2" | (middle button held down) |
xdotool mousedown "3" | (right button held down) |
xdotool mouseup "1-3" | (left-middle-right button held up |
The xdotool is a utility used from the terminal or in a script to manually perform keyboard input. The commands can also be used to manually perform actions on windows and perform mouse inputs.
The syntax for xdotool depends on the command being used. To send keystrokes to a window you use the 'key' command. The syntax is as follows: xdotool [options] [keys]. There are three options available for "options":
shutdown.sh #! /bin/bash xdotool key "super+t" & sleep 1 xdotool key type "sudo shutdown -h 0" & sleep 1 xdotool key "Return" & sleep 1 xdotool key type "password" & sleep 1 xdotool key "Return" & fi |
ispell.sh #! /bin/bash xdotool key "super+t" & sleep 1 xdotool key type "ispell" & sleep 1 xdotool key "Return" & fi |
Xdotool can be used in scripts to carry out commands that require typing in a terminal. For example, the spell helper ispell launches in the terminal by simply typing in ispell and clicking enter (Return) on the keyboard. The shell script ispell.sh, shown in the box on the right, put in ~/bin, made excutable and put in the menus or linked to the desktop will perform the same function with a single click. Here, xdotool key "super+t" launches the terminal (my keybinding to launch terminal), xdotool key type "ispell" types "ispell" into the terminal and xdotool key "Return" effectively strikes the enter or return key. The application inxi can be launched with a similar script with xdotool key type "inxi -F". It would appear this formula for creating shell launchers will work for just about any app launched in the terminal, which includes most linux apps. For a slightly more complicated example, see the launch script to create a shutdown button in the box on the left.
tlaunch.sh #! /bin/bash $@ /bin/bash |
Other xdotool tools: