How can I get a screenshot under Linux?

Duncan Roe
Duncan Roe used Ask the Experts™
Under Windows, Ctrl-Alt-PrintScreen gets me a screenshot of the selected window on the clipboard. (I believe plain PrintScreen gets the whole screen but I don't use that).
Is there an equivalent mechanism under Linux?
Distribution: Slackware
Window manager (aka desktop): fvwm95
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
alt + printscreen

same as windows - you don't need the "ctrl"
Duncan RoeSoftware Developer


Thanks for the link. Actually I already stumbled over Imagemagick as advertising to be able to capture screens while looking for something else before I read your post but you saved me having to drill down to find that import was the command to use.
This is what I use in my fvwm configuration:
Key Print	A	None	Exec ~/bin/ -w root -opng
Key Print	A	C	Exec ~/bin/ -w root -ojpg
Key Print	A	M	Exec ~/bin/ -w active -opng
Key Print	A	CM	Exec ~/bin/ -w active -ojpg

Open in new window

And ~/bin/ is:


help() {
	printf -- "%s -h|-w root|active [-o jpg|png] [-d dest_dir]\n" "${0}"
	printf -- "-h             - help\n"
	printf -- "-w root|active - take picture of desktop (root - default) or just active window\n"
	printf -- "-o jpg|png     - type of output file (default: png)\n"
	printf -- "-d dest_dir    - destination directory (default: $HOME)\n"

while getopts hw:o:d: opt; do
	case "${opt}" in
		h)	help; exit 0;;
		*)	help; exit 1;;

test -z "${WINDOW}" && WINDOW=root
test -z "${FORMAT}" && FORMAT=png
test -z "${DESTDIR}" && DESTDIR=$HOME

case "${WINDOW}" in
	root)	OPTS="-root";;
	active)	OPTS="-id `xprop -root | grep \"_NET_ACTIVE_WINDOW(WINDOW)\"| cut -d ' ' -f 5`";;
	*)	help; exit 2;;

TIMESTAMP=`date +%Y%m%d%H%M%S`

xwd ${OPTS} | convert - ${DESTDIR}/${TIMESTAMP}.${FORMAT}

Open in new window

oh well that's convinced me to switch from gnome to fvwm.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial