||This article includes a list of references, related reading or external links, but its sources remain unclear because it lacks inline citations. (June 2008)|
In the X Window System, xwd is a program for capturing the content of the screen or of a window and saving it into a file. xwd can be run in two ways: if user specifies the whole screen or the name or identifier of a window as an argument, the program captures the content of the window; otherwise, it changes the shape of the cursor and waits for the user to click in a window, whose content is then captured.
At the X Window core protocol level, xwd uses the fact that any X client can request the content of an arbitrary window, including ones it did not create, using the
GetImage request (this is done by the
XGetImage function in the Xlib library). The content of the whole screen is obtained by requesting the content of the root window.
$ xwd | xwdtopnm | pnmtopng > Screenshot.png