Hello.
Not sure if this is the right place to post, so feel free to move this to according place...
All the time i'm using puppy linux now i've been missing the ability to do a 'quick' screenshot of the active window like in Windows with ALT+PRINT.
TBH, in Windows you had to open a graphics editor and paste the image from clipboard, so it was not OOTB.
Here is a way to take the shot of the active window instantly:
Code: Select all
#!/bin/bash
[ -z "`which ffmpeg`" ] && echo "${0}: ffmpeg not found. Exiting..." 1>&2 && exit
[ -z "`which xdotool`" ] && echo "${0}: xdotool not found. Exiting..." 1>&2 && exit
WINID="-id `xdotool getactivewindow`"
[ "$WINID" = "-id " ] && WINID="-root" # if no window open
read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}' | tr '\n' ' '`
#xwininfo doesn't accept -frame and -id - need to manually calculate frame
read XPOS YPOS FRAME TITLE WIDTH HEIGHT <<< `xwininfo $WINID | sed -e '4,9!d' -e 's/.*: *//g' | tr '\n' ' '`
XPOS=$((XPOS - FRAME))
YPOS=$((YPOS - TITLE))
WIDTH=$((WIDTH + (2 * FRAME)))
HEIGHT=$((HEIGHT + FRAME + TITLE))
[ ${XPOS} -lt 0 ] && WIDTH=$((WIDTH + XPOS)) && XPOS=0
[ ${YPOS} -lt 0 ] && HEIGHT=$((HEIGHT + YPOS)) && YPOS=0
[ $((WIDTH + XPOS)) -ge $MAXX ] && WIDTH=$((MAXX - XPOS))
[ $((HEIGHT + YPOS)) -ge $MAXY ] && HEIGHT=$((MAXY - YPOS))
OFFSET="+${XPOS},${YPOS}"
OUTNAME="/root/quickshot-`date +%y%m%d-%H%M%S`.jpg"
ffmpeg -y -f x11grab -r 25 -s ${WIDTH}x${HEIGHT} -i ${DISPLAY}${OFFSET}+nomouse -c mjpeg -frames 1 "$OUTNAME" 2> /dev/null
defaultimageviewer "$OUTNAME" &
Paste code to a file in /usr/bin or /usr/local/bin, name it quickshot and make it executable.
NOTE: dependencies are ffmpeg and xdotool
If then you add/change in your /root/.jwm/jwmrc-personal:
Code: Select all
<Key mask="A" key="Print">exec:quickshot</Key>
you can take a shot of the active window without clicking any dialogs...