IgnorantGuru's Blog

Linux software, news, and tips

Screen Snapshots Using XWD

In KDE Free I described using Imagemagick’s “import” to take window and screen snapshots as a replacement for KSnapshot. Since then I have had problems with import leaving black areas on the snapshots, as another person describes here.

So I am now using X’s xwd instead, with the output piped through Imagemagick’s “convert”. Works with any DE. To set this as a keyboard shortcut in Openbox’s rc.xml:

  <keybind key="Print">
    <action name="Execute">
      <startupnotify>
        <enabled>false</enabled>
        <name>Snapshot</name>
      </startupnotify>
      <command>bash -c "xwd | convert - /tmp/screenshot-$(date +%s).png"</command>
    </action>
  </keybind>
  <keybind key="S-Print">
    <action name="Execute">
      <startupnotify>
        <enabled>false</enabled>
        <name>Snapshot with Frame</name>
      </startupnotify>
      <command>bash -c "xwd -frame | convert - /tmp/screenshot-$(date +%s).png"</command>
    </action>
  </keybind>
  <keybind key="C-Print">
    <action name="Execute">
      <startupnotify>
        <enabled>false</enabled>
        <name>Snapshot Fullscreen</name>
      </startupnotify>
      <command>bash -c "xwd -root | convert - /tmp/screenshot-$(date +%s).png"</command>
    </action>
  </keybind>

This makes the Printscreen key take a snapshot of window contents, Shift-Printscreen include the window frame, and Ctrl-Printscreen capture the whole screen. You can also use a .jpg extension for that format instead of .png, and can change /tmp to any folder where you want the screenshots saved.

And you’ll need to install imagemagick, of course.

June 7, 2010 Posted by | Tips | 2 Comments