Thorsten Zöller

Taking Screenshots on OpenBSD

I rarely need to take screenshots, but occasionally it is convenient to be able to do so. The method described here uses maim, cwm(1) and ksh(1). I use it on OpenBSD, but it should work in a very similar way on all Unix-like operating systems.

Here is how it works:

Preparation

Install maim:

# doas pkg_add maim

Create a script with the following content and save it to ~/bin/screenshot (assuming ~/bin is in the user's PATH):

#!/bin/sh

maim -s | xclip -selection clipboard -t image/png

All this script does is invoking maim to prompt the user to select the region of the screen he wants to take a screenshot of, upon which maim will create a PNG image of the region, which is then copied to the clipboard.

Make the script executable:

# cd ~/bin
# chmod u+x screenshot

Define a keybinding in ~/.cwmrc for invoking screenshot via the key combination Alt+s (of course, any other combination works as well):

bind-key M-s "bin/screenshot"

Define an alias in ~/.kshrc for pasting the image from the clipboard to a file:

alias clip2file='xclip -selection clipboard -o >'

That's it.

Taking a Screenshot

Then, to take a screenshot, do the following:

  1. Press Alt+s.

  2. Select the region of the screen you want to take a screenshot of.

  3. Go to a terminal and type:

    # clip2file <file>.png

The resulting screenshot will be saved to <file>.png.

See Also