I was looking again at the part, where the screenshots directory is determined and made some changes (mainly when I was looking for a free space option).
I'm using ksh since ages and miss the coprocess (&| with read -p) feature in bash. Even worse, variables in a piped "while do done" are not visible outside the block (since a subshell is created).
However here's the new code to get the first writeable sd card filesystem...
#!/bin/bash
# get first writeable mount dir on sd card or use users home dir
IFS=' '
while read xdev xon xdir xrest; do
# get all mount dirs
if [[ "$xdev" = /dev/mmcblk* && -w "$xdir" ]]; then
# writeable mount dir on sdcard device found, exit
mdir=$xdir
break
fi
done <<< $(mount | sort -f -k 3)
unset IFS
if [ "$mdir" = "" ]; then
# no writeable sdcard found, use users home directory
mdir=$HOME
fi
echo "mdir=$mdir"
It gets the first mounted directory in alphabetical order, which is hopefully a better chance, to get the left card slot first. I have 2 cards with volume labels PANDORA64A and PANDORA64B. If I first insert PANDORA64B into the right slot, it gets /dev/mmcblk0. If I later insert PANDORA64A into the left slot, it gets /dev/mmcblk1. So, if the 2 cards have a sequence naming convention like in my example, the left slot will be used, even though it's /dev/mmcblk1.
I tried to contact Gruso last week, but he's already offline for 2 weeks. Therefore I've attached a new PND version 1.0.2.0 to this post, for those where the old version doesn't work. Some error handling and additional information has been added as well (such as displaying the filename when taking a screenshot with F10 and a new short interval of 2 seconds).
Here the quick installation steps:
1. Copy the PND file to your /pandora/apps (or preferred) directory
2. In the Start Menu, select Other -> SnapSnap Installer (this activates F10 for screenshots)
There are 2 possibilities to take screenshots:
1. Press F10 to take a single screenshot (works only in X11, not in a emulator for instance)
2. In the Start Menu, select Graphics -> SnapSnap Timer (this takes screenshots in the specified interval, without pressing F10)
The script could be further enhanced by checking for free space.
Here an example to return the filesystem with the most free space...
#!/bin/bash
# get writeable mount dir on sd card with most space or use users home dir
IFS=' '
free_max=0
while read xdev xtot xused xfree xpct xdir xrest; do
# get all mount dirs
if [[ "$xdev" = /dev/mmcblk* && -w "$xdir" ]]; then
# writeable mount dir on sdcard device found, check free space
if [[ $xfree -gt $free_max ]]; then
# keep mount dir with most free space
free_max=$xfree
mdir=$xdir
fi
fi
done <<< $(df | sort -f -k 6)
unset IFS
if [ "$mdir" = "" ]; then
# no writeable sdcard found, use users home directory
mdir=$HOME
fi
echo "mdir=$mdir"
There's one drawback I see here. If 2 filesystems (or cards) have almost the same amount of free space, the script would swap between the cards while taking screenshots.
Any thoughts or comments?
snapsnap_1020.zip