Release SnapSnap: Take easy screenshots (repo release)


I have to answer yes here and thats going to be a problem I should have been aware of from square one right? Hence I've wasted your time on a massive scale by failing to have read the OP of your thread or some such. Bob Marley in the background doesnt help that potential realisation, you realise :)
 
That's ok, nor do the several bottles of stout in my belly.


I hadn't considered this scenario at all. And if you thought scripting wasn't my forte, you should see me try to solve permissions issues. I will definitely put a request out for some help on this - in the meantime I'll have to make another note on limitations in the OP.


Thanks for the testing and feedback. Better to discover these things early!
 
Last edited by a moderator:
No worries at all, I just thought I had need of chewing my fists off Arnold Rimmer style for a moment there.


I shall check the nand install and if it behaves as expected there first.


I would drink to the stout, or light up in relief but as a recently key holding former prisoner of many things of late, I have no desire to re-enter my cell anymore :)
 
Last edited by a moderator:
Beta 3 is up in first post. No major changes, just a little more finesse in the scripting.


Is anyone able to assist with getting this running from boot SDs? Please see MarioPandio's issue here:
 
Now uploaded to repo. Thanks to all for their help. Two outstanding items:

  • Still not working from boot SDs. (Sorry Mario... hang in there!) Input welcome, nay, needed on this.
  • No GUI for auto-timed shots, although instructions are included for doing this from terminal (very simple). If there's demand for a GUI option, I will look at it.
 
zenity gui's are really easy to add, you should look into that, or post your script and ill have a look at it. (not at home otherwise I would just exstract it.
 
Gruso, what's that roguelike you were playing? Looks interesting :)


MD593.png



D.
 
The Slimy Lichmummy!


http://repo.openpand...eSlimyLichmummy

zenity gui's are really easy to add, you should look into that, or post your script and ill have a look at it. (not at home otherwise I would just exstract it.
I now have a working GUI-controlled timer. Woo. :) I'll add it as a second app in the PND.

[edit] Repo & OP updated. Still no progress on bootSD issue.


[edit] There is now good progress on bootSD issue.


[edit] Now working from bootSD, repo update soon.
 
Last edited by a moderator:
Hey there,


A small bug spotted on SnapSnap :/


I'm running OS from the NAND, but with the SDCard partionned for an OS (meaning two partitions ROOT & BOOT).


The line which detect the left SD slot (the one containing th awk command) is detecting both partitions, so the


$dir variable contains "/media/ROOT /media/BOOT" and from there, everything fails :D


I think you need to tell awk to stop at first occurence found.


Anyhow, nice work :D


EDIT: found something: http://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file


So something like:awk '/\/dev\/mmcblk0p/ && !done { print $3; done=1;}'


may work.
 
Last edited by a moderator:
Heh, spent plenty of time making it work from both SD and NAND based OS but didn't take this scenario into account. Thanks for the report and the tip, I'll look into it when I can. :)
 
Hey there, A small bug spotted on SnapSnap :/ I'm running OS from the NAND, but with the SDCard partionned for an OS (meaning two partitions ROOT & BOOT). The line which detect the left SD slot (the one containing th awk command) is detecting both partitions, so the $dir variable contains "/media/ROOT /media/BOOT" and from there, everything fails :D I think you need to tell awk to stop at first occurence found. Anyhow, nice work :D EDIT: found something: http://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file So something like:awk '/\/dev\/mmcblk0p/ && !done { print $3; done=1;}' may work.
I haven't had any luck getting this to work yet. I noticed it will write to the right slot if a card is present, so that could be a workaround for now.

I did try another approach: Once the script determines you're running from NAND, it checks for /media/BOOT, and if present it will write screenshots there. If not present it falls back to the awk script to determine the left SD path. It works, but has some drawbacks:


- Hardcoding a mounted path into the script doesn't seem attractive. Even if the "ROOT/BOOT" card is the most common boot SD people are using.


- The script checks for this path before the awk line. So if you have a normal SD in the left slot which you are saving screenshots to, and you happen to insert a boot SD in the right slot, screenshot saving will switch to the boot SD.


Probably fine in 95% of scenarios, but the 5% haunts you sooner or later. I definitely think doing it with awk is preferable. I have some more head scratching to do.
 
I used your snapsnap tool today to make some screenshots, but I couldn't find the screenshot files. Then I checked the scripts and found out, it couldn't find my SD card (partition less card /dev/mmcblk0), the "dir" variable was empty and therefore it couldn't create the "/screenshots" directory.

filesystem=$(df | head -n 2 | tail -n 1 | awk '{ print $1 }')

if [ $filesystem = "/dev/root" ]; then # it's running from SD, so we'll use the homedir for screenshots
dir=$HOME
else # it's probably running from NAND, so we'll detect the path of the left SD card
dir=$(mount | awk '/^\/dev\/mmcblk0p/ {print $3}')
fiThe fix was easy, just replaced "mmcblk0p" with "mmcblk0" in the awk regex.
Instead of looking for a certain (single) device, you can use this code if you like:

#!/bin/bash

dir=$(
mount | while read dev on dir rest; do
# get all mounted directories
if [[ "$dev" = /dev/mmcblk* && -w "$dir" ]]; then
# writeable sdcard device found, echo & exit
echo $dir
break
fi
done
)

if [ "$dir" = "" ]; then
# no writeable sdcard found, use users home directory
dir=$HOME
fi

echo "dir=$dir"It loops through all mounted filesystems, checks whether the mount directory is writeable and returns the first SD card device. If nothing has been found, it uses $HOME.
Thanks for this utility. The timed mode is very useful.
 
Last edited by a moderator:
Great Yoshi !

Hope Gruso came back to this forum and update his utility :)
 
Last edited by a moderator:
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
 

Attachments

  • snapsnap_1020.zip
    146.8 KB · Views: 213
Last edited by a moderator:
I was thinking...why not ask the user where to write the screenshot just before use ?
 
Does not work on my Pandora, with disk SD card setup (all partitions have labels!):

Left slot: pa (FAT32, PND apps)  / pb (ext3, alternative boot volume, emptied it according to your bug warning) / swap-partition

Right slot: pm (FAT32, media files)

Is there a config where I can set the path?
 
Last edited by a moderator:
Back
Top