Duncan Roe
asked on
How can I get a screenshot under Linux?
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
Is there an equivalent mechanism under Linux?
Distribution: Slackware
Window manager (aka desktop): fvwm95
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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:
And ~/bin/ScreenShot.sh is:
Key Print A None Exec ~/bin/ScreenShot.sh -w root -opng
Key Print A C Exec ~/bin/ScreenShot.sh -w root -ojpg
Key Print A M Exec ~/bin/ScreenShot.sh -w active -opng
Key Print A CM Exec ~/bin/ScreenShot.sh -w active -ojpg
And ~/bin/ScreenShot.sh is:
#!/bin/sh
PATH=/usr/bin:/bin
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;;
w) WINDOW=${OPTARG};;
o) FORMAT=${OPTARG};;
d) DESTDIR=${OPTARG};;
*) help; exit 1;;
esac
done
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;;
esac
TIMESTAMP=`date +%Y%m%d%H%M%S`
xwd ${OPTS} | convert - ${DESTDIR}/${TIMESTAMP}.${FORMAT}
oh well that's convinced me to switch from gnome to fvwm.
same as windows - you don't need the "ctrl"