# xwd, the best X11 screen grabbing tool

xwd (1) is my favorite screen capture program for X Windows. Usage is simple:

xwd|xwdtopnm|pnmtopng>/tmp/screen.png   # Or:
xwd|xwdtopnm|pnmtojpeg>/tmp/screen.jpeg

Entering one of these commands, will give you a special pointer to click on the window you want to capture. That’s how simple it is to grab an X window with xwd.

You can also grab the whole screen with -root or exclude the window borders with -nobdrs. The manual page contains more options.

I was pretty elated when I first discovered xwd. I didn’t like having to invoke the GIMP, just for taking a quick screenshot. KDE and GNOME come with screenshot utilities, but sometimes I prefer other window managers (e.g.: this machine has been running WindowMaker from day one). Also the GNOME utility lost the option to exclude the window borders (in GNOME’s noble quest to become an appliance). All in all, I was glad to learn about a tool that I could count on to be available on most machines that have X Windows installed. Except, Gentoo has stripped many of these useful, little tools from the base install:

emerge x11-apps/xwd