Hi Rich,
Lately, I've found myself wanting to capture *) full screen captures, *) window captures and *) arbitrary-area-of-screen captures. The tools available in Tiny Core (17.1 / x86_64) are sufficient for this purpose - in fact I've placed an icon on my jwm tray to give access to all three:
left click = screenshot
middle click = windowshot
right click = grabber
But, if I use them a lot, my home directory gets cluttered up fast. I'm not using persistent home, so all of that clutter wants to go into mydata.tgz and... just no.
So I created directories on persistent storage for the screen capture files. Alas, grabber has a little config file where you can set the save path to somewhere other than $HOME but windowshot and screenshot don't. What I've done locally, and what I propose for the original windowshot and screenshot programs is to add logic allowing an optional argument, the save path, to be passed to these scripts. Below are the changes I've made to windowshot (not showing the screenshot one because, apparently, I made an unrelated change to that one about fifteen years ago):
Original windowshot:
[ -z ${DISPLAY} ] && echo "Requires X" && exit 1
which xwininfo > /dev/null
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5, 6 or 7)-bin.tcz" && exit 1
WINDOW_ID=`xwininfo -frame | grep " Window id:" | cut -d " " -f 4`
filename=windowshot-`date "+%Y%b%d-%H%M%S"`.png
/bin/sh -c "imlib2_grab -id $WINDOW_ID $HOME/$filename"
exec popup "Windowshot saved to $HOME/$filename"
Modified windowshot:
[ -n "${1}" ] && SAVEPATH="${1}" || SAVEPATH="${HOME}"
[ -d "${SAVEPATH}" ] || exec popup "windowshot: ERROR: ${SAVEPATH} not found"
[ -z ${DISPLAY} ] && echo "Requires X" && exit 1
which xwininfo > /dev/null
[ "$?" -ne 0 ] && exec popup "Requires xwininfo, see Xorg-7.(5, 6 or 7)-bin.tcz" && exit 1
WINDOW_ID=`xwininfo -frame | grep " Window id:" | cut -d " " -f 4`
filename=windowshot-`date "+%Y%b%d-%H%M%S"`.png
/bin/sh -c "imlib2_grab -id $WINDOW_ID $SAVEPATH/$filename"
[ -f "$SAVEPATH/$filename" ] && exec popup "Windowshot saved to $SAVEPATH/$filename" || exec popup "windowshot: ERROR: $SAVEPATH/$filename not saved"
Only two lines were added and two modified:
The first line of code (added) sets SAVEPATH to the first given argument, if there is one, otherwise defaulting to $HOME.
The second line (added), because I made plenty of typos while playing with this, bails with an error message if the specified save directory doesn't exist.
The next-to-last line (modified) substitutes $SAVEPATH for $HOME
The last line (modified), also substitutes $SAVEPATH for $HOME and I left in a check to only indicate success if the output file was actually created and to report an error if it was not.