Feel free to use this as a start for your own PND! This is pretty much the simplest PND possible. It will show a black screen for 2 seconds and then quit. Unfortunately, due to a bug in MiniMenu, this PND can only (as of HF5) be launched from XFCE.
- 1 MAKING SIMPLE PND
- 2 SimplePyTest.py
- 3 PXML.xml
- 4 Running Your Game
- 5 LAUNCHING A PND FROM TERMINAL
- 6 Usage
- 7 Arguments
- 8 Creating a launch script for PND
- 9 Modifying PNDs launch script(s) to accept arguments
- 10 Making Chromium the default browser of XFCE using the PND
- 11 Rationale
- 12 Presented methods ONLY apply per PND, do not affect general behavior
- 13 Method: Switch left/right nub unix devices
- 14 Method: Switch between nub configurator presets
MAKING SIMPLE PND
The PND has 2 files. First, "simplepytest.py", which is our executable application, and "PXML.xml" which the Pandora uses to launch the application correctly.
First, create a "simplepytest" folder in one of your application folders (i.e., "/pandora/menu").
This file is the actual application that the Pandora executes.
Create a file called "simplepytest.py" and put the following contents in it. This will display a black screen for 2 seconds at the current screen resolution, using Python and Pygame.
#! /usr/bin/python import pygame, pygame.locals import time pygame.init() vidInfo = pygame.display.Info() resolution = (vidInfo.current_w, vidInfo.current_h) pygame.display.set_mode(resolution, pygame.locals.FULLSCREEN) time.sleep(2)
This file contains the information the Pandora needs to figure out where to display your game and how to execute it.
Create a file called "PXML.xml" and put the following contents in it:
<?xml version="1.0" encoding="UTF-8"> <PXML xmlns="http://openpandora.org/namespaces/PXML"> <package id="simplepytest"> <version major="0" minor="0" release="0" build="1"/> <author name="YOUR NAME" email="YOUR EMAIL"/> <title lang="en_US">Simple Py Test</title> <titles> <title lang="en_US">Simple Py Test</title> </titles> </package> <application id="simplepytest"> <title lang="en_US">Simple Py Test</title> <titles> <title lang="en_US">Simple Py Test</title> </titles> <description lang="en_US">A Python and Pygame test program. </description> <version major="0" minor="0" release="0" build="1"/> <exec command="python simplepytest.py" /> <author name="YOUR NAME" email="YOUR EMAIL"/> <licenses> <license name="other"/> </licenses> <categories> <category name="Game"> <subcategory name="ArcadeGame"> </category> </categories> </application> </PXML>
Running Your Game
- Save all the above files.
- Make sure your Pandora is running the XFCE Gui.
- Unmount, then remove your SD card.
- Re-insert your SD card.
- The "Simple Py Test" game should appear in the Arcade Game folder.
LAUNCHING A PND FROM TERMINAL
It would be good to have basic shell scripting knowledge before proceeding with this article.
pnd_run.sh -p file.pnd -e cmd [-a args] [-b pndid] [-s path] [-c speed] [-d [path]] [-x] [-m] [-u] -p file.pnd : Specify the pnd file to execute -e cmd : Command to run -a args : Arguments to the command -b pndid : name of the directory mount-point (/mnt/utmp/pndid) (Default: name of the pnd file) -s path : Directory in the union to start the command from -o speed : Set the CPU speed -d [path] : Use path as source of the overlay. (Default: pandora/appdata/pndid) -x : Stop X before starting the apps -m : Only mount the pnd, dont run it (-e become optional) -u : Only umount the pnd, dont run it (-e become optional)
It is possible to execute the content of your pnd using arguments. This can be done by passing -a to pnd_run.sh with arguments quoted
-a "--arg 1"
Creating a launch script for PND
For a PND to function normally, you usually need to pass the appdata or PND ID (via -b) and correct executable (via -e) to the pnd_run.sh script. These can be found by examining PXML data that is appended in PNDs, or alternatively you can find IDs by using various package managers and executable paths by checking the .desktop files generated by the PND system. For the PND ID you would use the "appdata" entry of the PXML.xml, and, if absent, the application id. This will also determine the directory in pandora/appdata which will be used as base for the overlay. (As of this writing, the -d parameter is not evaluated.) For the -e parameter, you look for the "exec command" in the PXML.xml. This will determine the executable, which would be especially important in a multi-app-pnd.
pnd_run.sh -p /media/SD1/pandora/menu/Chromium.pnd -e "chrome.sh" -b "chromium" -a "$*"
Where chromium is the PND's ID found from PXML, and chrome.sh is the application found from .desktop file.
Modifying PNDs launch script(s) to accept arguments
With the Chromium.pnd it's not possible to use any additional arguments for the browser by default. This is because the launch script it uses does not expect arguments to be passed to it, and therefore does not pass them to chrome binary.
For example, the original chrome.sh from Chromium.pnd (as time of writing), looks like this:
#!/bin/sh # /mnt/utmp/chromium/chrome.sh HOME="/tmp" mkdir ./Default mkdir /tmp/chromium cp "First Run" /tmp/chromium/ ln -s /mnt/utmp/chromium/Default /tmp/chromium/Default export HOME export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH export XDG_CONFIG_HOME=$HOME ./chrome rm -r /tmp/chromium
Notice that it launches ./chrome and does not give any arguments for it.
As the original launch script resides in PND that is read-only file system, you can't modify it directly. However you can copy the script to that PND's appdata directory, which overrides the files of PND when mounted.
So copy it and modify this part:
So it should look like this in the end:
#!/bin/sh # /media/SD1/pandora/appdata/chromium/chrome.sh HOME="/tmp" mkdir ./Default mkdir /tmp/chromium cp "First Run" /tmp/chromium/ ln -s /mnt/utmp/chromium/Default /tmp/chromium/Default export HOME export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH export XDG_CONFIG_HOME=$HOME ./chrome $@ rm -r /tmp/chromium
There probably exists many more PNDs that don't expect arguments, and it's problematic when you actually need to pass them arguments, or make them as launchers for some file types. So you need to learn how to modify them.
Making Chromium the default browser of XFCE using the PND
Create launch script such as:
#!/bin/sh # /media/SD1/launchers/chromium.sh /usr/pandora/scripts/pnd_run.sh -p /media/SD1/pandora/menu/Chromium.pnd -e "chrome.sh" -b "chromium" -a "$*"
Save the script somewhere and make it as executable:
chmod +x /media/SD1/launchers/chromium.sh
Then go to Settings > Desktop > Preferred Applications, and point the Web Browser to your script. When opening URLs in XFCE environment, they should open in Chromium now.
If you want a different nub behavior for certain PND applications, you can achieve this by using one of the presented methods here.
Why would you want to do this? Simple; at least one person has reported that, when playing a natively-ported FPS (like Duke Nukem or Quake, but not GoldenEye) on the Pandora, using the right nub as the mouse has proven to be more comfortable and less awkward. But switching nub modes manually is annoying; so let's have Linux do it for you!
Presented methods ONLY apply per PND, do not affect general behavior
The methods below are crash save, as the nub behavior is changed by the process pnd_run.sh, which runs before AND after a PND is running. Thus even in the event that your PND application crashes, your nub configuration WILL be the same as before you started the PND with the custom nub behavior. (Source: sebt3 forum post)
Method: Switch left/right nub unix devices
Hint from: Blue Protoman
Open a text editor and copy/paste this:
cat /proc/pandora/nub0/mode > /tmp/nub0mode_before cat /proc/pandora/nub1/mode > /tmp/nub1mode_before /usr/pandora/scripts/op_nubchange.sh mbuttons mouse
This will back up your current nub modes, then switch them; the left will act as the mouse buttons, the right will act as the mouse. If you'd like, you can substitute "scroll" or "absolute" (joystick) in, depending on how you like your nubs. But you must save this as PND_pre_script.sh. Save it wherever you'd like, you will be moving it elsewhere later.
Note: op_nubchange.sh script might not available in older firmwares. See Kernel interface page for more information.
Copy/paste this into the editor again. Different file this time.
nub0mode=`cat /tmp/nub0mode_before` nub1mode=`cat /tmp/nub1mode_before` /usr/pandora/scripts/op_nubchange.sh $nub0mode $nub1mode rm /tmp/nub0mode_before /tmp/nub1mode_before
This will restore your nub modes to what they were before, and delete the temporary files used to store them. You must save it as PND_post_script.sh.
Simply copy these files into the appdata folder of your program of choice! Now you're done. If you want to test it, drag these files into the appdata of a program that runs windowed (like Comix or Deadbeef), so you can test with the mouse. Simply delete the files if you no longer desire their effects.
Method: Switch between nub configurator presets
Hint from: Caine
- Start the nub configurator
- Create a profile for the setup you wish your application to use.
- Below, I'll assume a profile is created which is called joysticks which places both nubs in joystick mode.
- Create a file PND_pre_script.sh with this content:
- /usr/pandora/scripts/op_nubmode.py -s temp_profile -p joysticks
- This will store the current configuration in a profile called temp_profile and next will load the joysticks profile.
- Create a file PND_post_script.sh with this content:
- /usr/pandora/scripts/op_nubmode.py -p temp_profile -d temp_profile
- This will load the previously created profile temp_profile and will remove it afterwards.
- Simply copy the files PND_pre_script.sh and PND_post_script.sh into the appdata folder of your program of choice!
Uses the GUI to easily create custom profiles without having to know where values are written to.
- It is slower, uses some memory and writes profiles to NAND.
- If you want to avoid NAND-writes per launch and you always revert back to the same profile after launch then you can use static profiles without having to save and remove the current. E.g. something like:
- Before: /usr/pandora/scripts/op_nubmode.py -p joysticks
- After: /usr/pandora/scripts/op_nubmode.py -p Default