Guide: Screenshots


Joined
May 17, 2010
Messages
2,198
Location
:|
You may not know this, but your Pandora comes with a nice little shell command to make screenshots. The two problems that have to be overcome when using it are:

1) You have to specify a filename

When running the command, you specify a filename and path for the screenshot to be saved (in the PNG image format). This is a pain when you want to do multiple screen dumps! It means you have to make up a filename for each screenshot, or write over the previous one.

2) You have to run it from the terminal

Not only is typing in the full command rather tedious, but to run it you have to bring up a terminal window. Not much fun unless you want screenshots of a terminal window running the screenshot program!

In this guide, we'll overcome these problems as follows:

1) Auto increment filenames

We'll use a little Linux magic to append the filename with the date and time, giving it a unique name. We'll also specify the path to be your home directory, which is a reliable location for Linux to use (it will always be there).

2) Print Screen key

We'll wrap all the commands into a script and install it on the nand (internal) memory. This means that any program on your Pandora can invoke (run) a screenshot without having to bring up a terminal window. Our script will also have a little XFCE popup near the taskbar to inform us when we take screenshots.

After all this is done, we'll map it to a keyboard shortcut so it can be used anywhere on the XFCE desktop (although this won't work inside games or minimenu because the shortcuts rely on XFCE).

Part 1 - Making and installing the script

Paste the following into Mousepad and save it somewhere (I recommend the home directory) as 'snapsnap.sh' (although you can give it any name you like, just remember what you called it).

Code:
#!/bin/bash
fbgrab ~/screen`date +%y%m%d-%H%M%S`.png
notify-send snapsnap

Breakdown of what it does:

'#!/bin/bash' - We're telling Linux "Hey! This file is a script!". Bash is a shell for Linux that runs inside a terminal. What's the difference? Well the terminal program, or any terminal in Linux, just deals with taking in lines of text (the line you typed in) and output text from the shell. You can consider it a frontend for the shell, which does all the actual work of figuring out what to do with your inputted text, and what to send back to you. The shell itself talks to Linux, like a middle man.

'fbgrab' - The utility for making screendumps. 'fb' refers to the 'frame buffer' which is the technical term for all the pixels on your screen at any one time, stored in memory.

'~/' - A shortcut for Linux that refers to your current home directory. If you change users, this location changes with it.

`date +%y%m%d-%H%M%S` - These are not quotation marks, everything inside these little marks will be figured out seperately, then the result will appear as if the command inside them never existed. You can think of it like how in algebra, the contents of brackets are worked out first. The command we are running is 'date', which just lists the current date or time. We have passed parameters to it, in the format it expects to say we want 'year,month,day-hour,minute,second'. This is then spliced into the full filename.

'notify-send snapsnap' - Another Linux utility to send pop-up notifications on the taskbar. We are making it say 'snapsnap' so we can be sure a screenshot has been taken!


Install this script to the Nand

We need to make this file executable first. Go to the folder you saved it in using Thunar, then rightclick 'open terminal here'.

Type one of the following in and hit enter:

Code:
chmod ugo+rwx snapsnap.sh
^give access to all users
Code:
chmod +x snapsnap.sh
^give executable access to the current user (the one you are logged in as)

Breakdown of what that did:

chmod - Another security feature is that files can be marked as executable or not, and who can read, write and execute them. Each file has individual 'permissions' on how it can be used.

'ugo' - We are saying 'please change permissions for this user (U), all members of this users group (g) and anyone outside the users group (O - other).

'+' - 'Please set these permissions to positive!' In other words, a highlighted tick box or 'on' switch.

'rwx' - 'Please change those permissions for reading the file ( r ), writing the file (w) and executing (x)


Now try and run the script!

Code:
./snapsnap.sh

You see a popup saying 'snapsnap' and a screenshot should appear in your home directory. Nice one!

Installing this script

Type the following and hit enter:

Code:
sudo cp snapsnap.sh /usr/bin/snapsnap


Sudo - Stands for 'superuser do'. We are saying 'run this admin command please' and then sudo will say 'Okay fine, but give me your password!'. This is a Linux security feature to prevent hackers and bad scripts (in theory) from messing up your system without asking you first.

/usr/bin is where commands live. From here they can be executed anywhere on your system. At the moment you need to be in the folder you saved it to. We are removing the '.sh' because this means to run the command you only have to type 'snapsnap'. It's a good idea to leave the draft versions with the .sh on the end, so you know they are shell scripts!


Now type the following and hit enter:

Code:
snapsnap

Congrats, you should now have two screenshots of you making screenshots!

Keyboard shortcut

Open up the keyboard shortcut settings (settings->keyboard from the menu).

Go to the tab 'Application shortcuts'.

Drag the window up with shift(also the left shoulder button) and drag (you can drag anywhere on the window).

Click 'add'.

Now it wants a command to run. Type in 'snapsnap' (without the quotations).

Hit okay or press enter.

Now it wants a keyboard shortcut. Use something obscure that won't already be used by applications. I recommend something like ctrl-alt-s.

Now one final thing

Open up mousepad. Type 'I made a screenshot'. Press your keyboard shortcut. Post it in this thread.

\m/
 
Nicely written guide, but a couple of minor points:

1) You don't need to sudo to change permissions on your own files.
2) The permissions are excessive: chmod +x should be enough.

I wouldn't usually be so pedantic, but seeing as this has obviously been written with novice users in mind, it'd be better not to teach them bad habits.
 
Wow, this would be a nice thing to be included in the next Firmware update. :)
I want a Screenshot function and I will try it when I have my Pandora. You made good explanations of all these cryptic command-shortcuts, very nice.^^
Uh, But where are the actual Screenshots stored at the end? In the home directory onto NAND? Or just in the Clipboard like onto the PC, when you hit the "print" button? I would prefer clipboard (if Pandora has one) or a directory onto the SD-Card instead of the NAND. ;)
 
SteveM said:
Nicely written guide, but a couple of minor points:

1) You don't need to sudo to change permissions on your own files.
2) The permissions are excessive: chmod +x should be enough.

I wouldn't usually be so pedantic, but seeing as this has obviously been written with novice users in mind, it'd be better not to teach them bad habits.

Yeah, I accidentally added that sudo. Doh.

Also, is it so bad to allow full access to a screenshot utility?

I just give everything full privileges... it's not like I'm running a web server or something! I can warn people about that maybe.

EDIT: listed both options
 
Last edited by a moderator:
fusion_power said:
Uh, But where are the actual Screenshots stored at the end?

It makes a new file in your home directory. It doesn't make sense to me to use an SD card path, considering they are always changing.

But if you want that, just change the path to '/media/YOURSD' or '/media/mmcbBLAHBLAH'.

There's nothing to stop you making a screenshot key for each memory card! Linux is awesome like that.
 
Last edited by a moderator:
So i can't run xfce and then start an app, say an emulator, from inside and take screenshots? Why, isn't xfce running in the bg?
 
SomeGuy99 said:
fusion_power said:
Uh, But where are the actual Screenshots stored at the end?

It makes a new file in your home directory. It doesn't make sense to me to use an SD card path, considering they are always changing.

But if you want that, just change the path to '/media/YOURSD' or '/media/mmcbBLAHBLAH'.

There's nothing to stop you making a screenshot key for each memory card! Linux is awesome like that.
The script could be always onto NAND (so you don't need one at the SDs), but the Screenshot Folder should be onto SD. ;) I imagine that the script automaticly generates an SCREENSHOTS Folder onto SD if there is none (you first decide, where this folder will be) . If I read your guide right then the script has to be where the Screenshots are stored. (sorry, my english is not that good ^^" )
 
Last edited by a moderator:
Wolfsclaw said:
So i can't run xfce and then start an app, say an emulator, from inside and take screenshots? Why, isn't xfce running in the bg?

It won't run because when you run a game, it grabs the keys for itself!

fusion_power said:
The script could be always onto NAND (so you don't need one at the SDs), but the Screenshot Folder should be onto SD. ;) I imagine that the script automaticly generates an SCREENSHOTS Folder onto SD if there is none (you first decide, where this folder will be) . If I read your guide right then the script has to be where the Screenshots are stored. (sorry, my english is not that good ^^" )

If you want it save to SD, use something like this:

Code:
#!/bin/bash
fbgrab /media/mmcblk0p1/screen`date +%y%m%d-%H%M%S`.png
notify-send snapsnap

That saves it to the first memory card. The problem is that the paths change all the time - if you take out the card and put it back in, the location changes!

The 'sd fix' patch changes the SD paths to the disk names. So mine would be '/media/astro'.

But what if I want to save to a different card?

The best solution would be a cominbation of two scripts:

The first one (on the nand) looks for the screenshot script on inserted media. The second one is the screenshot script, located on your memory card (in say a 'screenshot' folder).

The first one executes the second one. The second one stores the screenshots in it's own folder.

Want me to write that for you?

At the moment it saves to your home folder. Screenshots are about 300k, so ten of them will be 3mb. So long as you clean it up every so often, it's not gonna fill up your nand. You could easily store a hundred, two hundred even on the default firmware.

A Zenity script could pop up a window asking you the location to save your screenshot, but I personally find that annoying and tedious. :)
 
Last edited by a moderator:
SomeGuy99 said:
That saves it to the first memory card. The problem is that the paths change all the time - if you take out the card and put it back in, the location changes!

The 'sd fix' patch changes the SD paths to the disk names. So mine would be '/media/astro'.
Sounds very complicated. Why should a path change? When I tell a Programm, that it have to store the Screensots ALWAYS under SD/Screenshots (SD1) for example it shouldn't actualy matter if you change the SD card. If there is no folder, it generates one - done. ^^
Why is Linux always so unser-unfriendly and complicated?

SomeGuy99 said:
At the moment it saves to your home folder. Screenshots are about 300k, so ten of them will be 3mb. So long as you clean it up every so often, it's not gonna fill up your nand. You could easily store a hundred, two hundred even on the default firmware.
AFAIK deleting in Pandora doesn't delete anything at the moment but writes even more to the NAND. (trash can) :(
 
Last edited by a moderator:
fusion_power said:
SomeGuy99 said:
That saves it to the first memory card. The problem is that the paths change all the time - if you take out the card and put it back in, the location changes!

The 'sd fix' patch changes the SD paths to the disk names. So mine would be '/media/astro'.
Sounds very complicated. Why should a path change? When I tell a Programm, that it have to store the Screensots ALWAYS under SD/Screenshots (SD1) for example it shouldn't actualy matter if you change the SD card. If there is no folder, it generates one - done. ^^
Why is Linux always so unser-unfriendly and complicated?

SomeGuy99 said:
At the moment it saves to your home folder. Screenshots are about 300k, so ten of them will be 3mb. So long as you clean it up every so often, it's not gonna fill up your nand. You could easily store a hundred, two hundred even on the default firmware.
AFAIK deleting in Pandora doesn't delete anything at the moment but writes even more to the NAND. (trash can) :(

Do you have a Pandora yet?

The mountpoints change all the time. It's something that Ed and the team are working on. Besides, there are different paths to each SD card slot... but you can specify the first or second (see the example I gave you).

There is an sd card fix that changes the mountpoint to the name of the memory card, and this breaks any fixed paths to the SD cards.

The whole reason stuff like PND was made was because you cannot rely on paths to the SD cards for programs. If you want that, you're best off running the script from your SD card itself... but then the path to this itself is then subject to change! That's why a one line 'finder' script to find that one would work.

If you read the hotkeys guide I made, I give an example of how to find a PND on any card, so you don't need fixed paths.

The trash can is a right pain... but you can delete files properly from the command line (or using say Midnight Commander which is what I do).

You could even make a script or shortcut key to delete all the screenshots from you home! Linux can do pretty much whatever you want it to, you just have to use your imagination B)

An entry can be added to the right-click in Thunar to do absolute deletion, but I haven't tried yet.

It's no less user friendly than Windows really, which will dynamically assign a drive letter on insertion and removal. You can't rely on fixed paths there either. Try plugging a load of memory dongles in random order and see what it does.

The only fixed path you can rely on is the NAND, because you're not taking it in and out all the time.

Don't forget guys: You're in 'Software Hacking'. I kind of assumed people reading these guides would be interested in hacking together solutions.
 
Last edited by a moderator:
Rather than hacking in solutions, perhaps developers could add a screenshot function to their games and apps.?

This really is pretty simple for the most part and there's such a small library of games/apps. available that maybe this could become a Pandora standard, with a possible standard key/combination to do this?
 
SomeGuy99 said:
Do you have a Pandora yet?
No, but I want to be prepared. :)

This "random" path thing doesn't make sense for me and sonds somewhat unlogic but I guess it's one of many Linux "features". :D

If "Midnight Commander" really rund onto the Pandora, I guess I will use it, I'm a fan of "Total Commander" on my Windows PC and I love these "Double side" File managers. If Shift+delete really deletes a file instead of writing it to the NAND, it should be comfortable enough.
I guess this "random path" thing also prevents from puting the trash can folder straight onto an SD. ^^"
 
Last edited by a moderator:
fusion_power said:
SomeGuy99 said:
Do you have a Pandora yet?
No, but I want to be prepared. :)

This "random" path thing doesn't make sense for me and sonds somewhat unlogic but I guess it's one of many Linux "features". :D

If "Midnight Commander" really rund onto the Pandora, I guess I will use it, I'm a fan of "Total Commander" on my Windows PC and I love these "Double side" File managers. If Shift+delete really deletes a file instead of writing it to the NAND, it should be comfortable enough.
I guess this "random path" thing also prevents from puting the trash can folder straight onto an SD. ^^"

The trash can folder is virtual I think, you can't just move it anywhere.

The paths to the memory card slots are not random as such:

/media/mmcblk0p1 = memory card 1
/media/mmcblk1p1 = memory card 2

But at the moment, when you take a card out and put it back in, the file names increment:

/media/mmcblk2p1 or something like that

So all your paths break. It's a bug that ED and co and working on.
 
Last edited by a moderator:
SomeGuy99 said:
/usr/sbin is where scripts live. From here they can be executed anywhere on your system.
Err, no. "sbin" stands for "system binaries", and the folder was originally intended to only be accessible by root (because all of the binaries there only concern the system admin, and normal users should therefore only have to see /usr/bin). So, the script *should* be copied to /usr/bin.
 
Last edited by a moderator:
dflemstr said:
SomeGuy99 said:
/usr/sbin is where scripts live. From here they can be executed anywhere on your system.
Err, no. "sbin" stands for "system binaries", and the folder was originally intended to only be accessible by root (because all of the binaries there only concern the system admin, and normal users should therefore only have to see /usr/bin). So, the script *should* be copied to /usr/bin.

does this mean i should put the snapsnap script in usr/bin ?
 
Last edited by a moderator:
dflemstr said:
SomeGuy99 said:
/usr/sbin is where scripts live. From here they can be executed anywhere on your system.
Err, no. "sbin" stands for "system binaries", and the folder was originally intended to only be accessible by root (because all of the binaries there only concern the system admin, and normal users should therefore only have to see /usr/bin). So, the script *should* be copied to /usr/bin.

Fair enough. I need knowledgable people to tell me this stuff!

I'll edit all my guides accordingly. :)

EDIT: I got it a little mixed up.

I was thinking of /usr/local/sbin, which is the location for installing scripts. Easy to confuse no?

paddy said:
does this mean i should put the snapsnap script in usr/bin ?

It works from both, but to please Linux gurus then... yeah B)

I don't think anything will bad will happen if you leave it in /usr/sbin.
 
Last edited by a moderator:
SomeGuy99 said:
I was thinking of /usr/local/sbin, which is the location for installing scripts. Easy to confuse no?
That is the location for user-common locally-generated system-binaries (See, folder names in Linux *do* make sense once you learn the scheme ;)), so no, still not a place for scripts. Scripts are like any other executable; they aren't treated differently from ELF binaries.
 
Last edited by a moderator:
dflemstr said:
SomeGuy99 said:
I was thinking of /usr/local/sbin, which is the location for installing scripts. Easy to confuse no?
That is the location for user-common locally-generated system-binaries (See, folder names in Linux *do* make sense once you learn the scheme ;) ), so no, still not a place for scripts. Scripts are like any other executable; they aren't treated differently from ELF binaries.

Oh well. I thought dumping a script into /usr/bin was bad form. Thanks for correcting me :)

I edited all my guides anyway.
 
Last edited by a moderator:
Random paths aren't strange at all. The SD CARDS contain the filesystems the Pandora mounts in a path in it's root tree ("/"), commonly in a folder for such mounts ("/media/"). The SD SLOTS on the other hand, are merely the physical tools the device make use of to be able to read and write to the filesystems. Again, located inside every individual card (one card can even have several filesystems, via partitioning!).

Therefore, it's quite easy to understand why each individual card will get a new path. When the same card is inserted again, it isn't automatically remembered and assigned the same path, it's incremented to ensure two filesystems doesn't collide. It would be strange however, to assign the same path to all cards read and written through the same slot, wouldn't it?
 
Back
Top