Removed scripts from libpnd
authorMichael Mrozek <EvilDragon@openpandora.de>
Tue, 22 Feb 2011 23:11:28 +0000 (00:11 +0100)
committerMichael Mrozek <EvilDragon@openpandora.de>
Tue, 22 Feb 2011 23:11:28 +0000 (00:11 +0100)
testdata/scripts/genpxml.sh [deleted file]
testdata/scripts/op_battlow.sh [deleted file]
testdata/scripts/op_bright_down.sh [deleted file]
testdata/scripts/op_bright_up.sh [deleted file]
testdata/scripts/op_lid.sh [deleted file]
testdata/scripts/op_menu.sh [deleted file]
testdata/scripts/op_power.sh [deleted file]
testdata/scripts/pnd_hup.sh [deleted file]
testdata/scripts/pnd_make.sh [deleted file]
testdata/scripts/pnd_run.sh [deleted file]

diff --git a/testdata/scripts/genpxml.sh b/testdata/scripts/genpxml.sh
deleted file mode 100755 (executable)
index f859bfa..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-if [ $1 ]; then cd $1; fi
-for x in $(pwd)/*
-do
-if [ -x $x ] && [ ! -d $x ] && [ ! $(echo $x | cut -d . -f 2 -s) ] ; then exe=$x; break; fi
-done
-BASENAMEnoex=$(basename "$exe" | cut -d'.' -f1)
-BASENAME=$(basename "$exe")
-rnd=$RANDOM;
-loc=$(dirname "$0")
-echo '
-<?xml version="1.0" encoding="UTF-8"?>
-<PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd">
-
-  <application id="'$BASENAME-$rnd'">
-    <exec command="'$BASENAME'"/>
-
-    <title lang="en_US">'$BASENAMEnoex'</title>
-    <title lang="de_DE">'$BASENAMEnoex' - German (lol!)</title><!--optional, only one title tag required-->
-    <author name="'$USERNAME'" website="http://www.openpandora.org"/><!--Optional email and website, name required-->
-    <version major="1" minor="1" release="1" build="2"/><!--This programs version-->
-    <osversion major="1" minor="0" release="0" build="0"/><!--The minimum OS version required, optional-->
-    <description lang="en_US">en_US Automatically generated pxml from'$(pwd)' exe='$BASENAME'</description>
-    <description lang="de_DE">de_DE Automatisch generiertes pxml aus'$(pwd)' exe='$BASENAME'</description>
-    <!-- if you want to provide an icon, uncomment the following line and set correct filename! -->
-    <!-- <icon src="icon.png"/> -->
-    <previewpics>'
-#add all images in the folder as preview pics
-for image in $(file -i -0 * | grep -a image | cut -d" " -f1)
-do
-echo "      <pic src="$image"/>"
-done
-echo '    </previewpics>
-    <!-- if you want to provide a manual, uncomment the following line and set correct values! -->
-    <!-- <info name="'$BASENAMEnoex' manual" type="text/html" src="manual.html"/> -->
-    <categories>
-    <!-- for information about valid categories and explainations of them, please have a look at this website:
-         http://standards.freedesktop.org/menu-spec/menu-spec-latest.html#category-registry
-         entries with invalid category/subcategory combinations will appear under "others" in the menus! -->
-      <category name="Main category">
-      <!--valid values for "Main category": "AudioVideo", "Audio", "Video", "Development", "Education", "Game", "Graphics", "Network", "Office", "Settings", "System", "Utility"-->
-        <subcategory name="Main Subcategory"/>
-        <!--valid Values for "Subcategory": "Building", "Debugger", "IDE", "GUIDesigner", "Profiling", "RevisionControl", "Translation", "Calendar", "ContactManagement", "Database", "Dictionary", "Chart", "Email", "Finance", "FlowChart", "PDA", "ProjectManagement", "Presentation", "Spreadsheet", "WordProcessor", "2DGraphics", "VectorGraphics", "RasterGraphics", "3DGraphics", "Scanning", "OCR", "Photography", "Publishing", "Viewer", "TextTools", "DesktopSettings", "HardwareSettings", "Printing", "PackageManager", "Dialup", "InstantMessaging", "Chat", "IRCClient", "FileTransfer", "HamRadio", "News", "P2P", "RemoteAccess", "Telephony", "TelephonyTools", "VideoConference", "WebBrowser", "WebDevelopment", "Midi", "Mixer", "Sequencer", "Tuner", "TV", "AudioVideoEditing", "Player", "Recorder", "DiscBurning", "ActionGame", "AdventureGame", "ArcadeGame", "BoardGame", "BlocksGame", "CardGame", "KidsGame", "LogicGame", "RolePlaying", "Simulation", "SportsGame", "StrategyGame", "Art", "Construction", "Music", "Languages", "Science", "ArtificialIntelligence", "Astronomy", "Biology", "Chemistry", "ComputerScience", "DataVisualization", "Economy", "Electricity", "Geography", "Geology", "Geoscience", "History", "ImageProcessing", "Literature", "Math", "NumericalAnalysis", "MedicalSoftware", "Physics", "Robotics", "Sports", "ParallelComputing", "Amusement", "Archiving", "Compression", "Electronics", "Emulator", "Engineering", "FileTools", "FileManager", "TerminalEmulator", "Filesystem", "Monitor", "Security", "Accessibility", "Calculator", "Clock", "TextEditor", "Documentation", "Core", "KDE", "GNOME", "GTK", "Qt", "Motif", "Java", "ConsoleOnly"-->
-        <subcategory name="Subcategory 2"/>
-      </category>
-      <category name="Alternative category">
-        <subcategory name="Alternative Subcategory 1"/>
-      </category>
-    </categories>
-    <!-- if you want to set a fixed clockrate differening from the default (500MHz), uncomment the following line and set it to the value you want (in MHz) -->
-    <!-- <clockspeed frequency="600"/> -->
-
-  </application>
-
-</PXML>
-'
diff --git a/testdata/scripts/op_battlow.sh b/testdata/scripts/op_battlow.sh
deleted file mode 100755 (executable)
index de4e21a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#usage op_shutdown.sh time in seconds
-xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
-time=$1
-if [ x$time = "x" ]; then
-       time=30
-fi
-countdown () {
-  for i in $(seq $time); do
-    percentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }')
-    echo $percentage
-    remain=$(echo $time $i | awk '{ printf("%d\n", $1-$2) }')
-    echo "# Low power, shutdown in $remain"
-    sleep 1
-  done
-}
-countdown  | su -c 'DISPLAY=:0.0  zenity --progress --auto-close --text "Shutdown" --title "Shutdown"' $xfceuser
-if [ $? -eq 0 ]; then
-    shutdown -h now
-else
-    su -c 'DISPLAY=:0.0  zenity --error --text "`printf "Shutdown aborted! \n
-Please plug in the charger ASAP or shutdown manually, the System will crash in a few minutes"`"' $xfceuser
-fi
diff --git a/testdata/scripts/op_bright_down.sh b/testdata/scripts/op_bright_down.sh
deleted file mode 100755 (executable)
index 2e79385..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-cur=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness);
-if [ "$cur" -gt "40" ]; then
-   new=$(($cur-10))
-elif [ "$cur" -gt "30" ]; then 
-   new=$(($cur-7))
-elif [ "$cur" -gt "20" ]; then 
-   new=$(($cur-5))
-elif [ "$cur" -gt "5" ]; then 
-   new=$(($cur-3))
-elif [ "$cur" -gt "0" ]; then 
-   new=$(($cur-1))
-fi
-
-if [ "$new" -lt "3" ]; then
-   new=0
-fi
-
-echo $new > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
diff --git a/testdata/scripts/op_bright_up.sh b/testdata/scripts/op_bright_up.sh
deleted file mode 100755 (executable)
index 2619004..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-cur=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness);
-if [ "$cur" -gt "35" ]; then
-   new=$(($cur+10))
-elif [ "$cur" -gt "20" ]; then 
-   new=$(($cur+7))
-elif [ "$cur" -gt "13" ]; then 
-   new=$(($cur+5))
-elif [ "$cur" -gt "5" ]; then 
-   new=$(($cur+3))
-elif [ "$cur" -gt "0" ]; then 
-   new=$(($cur+1))
-elif [ "$cur" -eq "0" ]; then 
-   new=3
-fi
-
-if [ "$new" -gt "54" ]; then
-   new=54
-fi
-
-
-
-echo $new > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
diff --git a/testdata/scripts/op_lid.sh b/testdata/scripts/op_lid.sh
deleted file mode 100755 (executable)
index 757abcd..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-#actions done when the lid is closed
-#only argument is 0 for open 1 for closed
-#may also be called after inactivity, like X DPMS
-
-if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
-  if [ "$1" = "1" ]; then #lid was closed
-    brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
-    if [ $brightness -gt 0 ]; then
-      echo $brightness > /tmp/oldbright
-    fi
-    echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
-    #echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
-  elif [ "$1" = "0" ]; then # lid was opened
-    #echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
-    #sleep 0.1s # looks cleaner, could flicker without
-    maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
-    oldbright=0
-    if [ -f /tmp/oldbright ]; then
-      oldbright=$(cat /tmp/oldbright)
-    fi
-    if [ $oldbright -eq 0 ]; then
-      oldbright=$(cat /etc/pandora/conf/brightness.state)
-    fi
-     if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
-      /usr/pandora/scripts/op_bright.sh $oldbright 
-     else
-      /usr/pandora/scripts/op_bright.sh $maxbright
-     fi
-  fi
-fi
diff --git a/testdata/scripts/op_menu.sh b/testdata/scripts/op_menu.sh
deleted file mode 100755 (executable)
index 6aef745..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-#actions done when the menu button is pressed
-#only argument is the time the button was pressed in  seconds
-
-if [ "$1" -ge "2" ]; then #button was pressed 3 sec or longer, show list of apps to kill instead of launcher
-  killist=y
-fi
-
-xpid=$(pidof xfce4-session)
-if [ $xpid ]; then
-  echo "xfce4 is running"
-  # note: max username length ps can output is 19, otherwise it prints uid
-  xfceuser=$(ps -o user:20= -C xfce4-session | tail -n1 | awk '{print $1}')
-  if [ $killist ]; then
-    echo "displaying kill list"
-    pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*-\(.*\)(\([0-9]\+\))/\2\n \1/p' | su -c 'DISPLAY=:0.0 zenity --list --multiple --column "pid" --column "name" --title "kill" --text "which apps should be killed"' - $xfceuser | sed 's/|/\n/')
-    for PID in $pidlist
-    do
-      kill -9 $PID
-    done
-  else
-    # echo "starting appfinder"
-    # invoke the appfinder; nice app, but it takes a few seconds to come up
-    #su -c 'DISPLAY=:0.0 xfce4-appfinder' - $xfceuser
-    # invoke the bottom-left popup menu, for launching new apps, instead.
-    popuppid=$(pidof xfce4-popup-menu)
-    if [ $popuppid ]; then
-       echo "popup menu is already running"
-    else
-       su -c 'DISPLAY=:0.0 xfce4-popup-menu' - $xfceuser
-    fi
-  fi
-else
-  echo "no x, killing all pnd aps so x or DE gets restarted"
-  pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
-  for PID in $pidlist
-  do
-    kill -9 $PID
-  done
-fi
diff --git a/testdata/scripts/op_power.sh b/testdata/scripts/op_power.sh
deleted file mode 100755 (executable)
index aabc8bd..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/bash
-#actions done when the power button is pressed
-#only argument is the time the button was pressed in  seconds
-
-if [ "$1" -le "2" ]; then # button was pressed 1-2sec, "suspend"
-  if [ -e /tmp/powerstate ]; then 
-    powerstate=$(cat /tmp/powerstate)
-  else
-    powerstate=0
-  fi
-  if [ $powerstate -eq "1" ]; then
-    #in lowpower mode
-    oldspeed=$(cat /tmp/oldspeed)
-    /usr/pandora/scripts/op_cpuspeed.sh $oldspeed
-    echo 0 > /tmp/powerstate
-    oldbright=$(cat /tmp/oldbright)
-    maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
-    echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
-    sleep 0.1s # looks cleaner, could flicker without
-    oldspeed=$(cat /tmp/oldspeed)
-    if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
-      /usr/pandora/scripts/op_bright.sh $oldbright 
-    else
-      /usr/pandora/scripts/op_bright.sh $maxbright
-    fi
-    hcistate=$(cat /tmp/hcistate)
-    if [ ! $hcistate ]; then
-      hciconfig hci0 up
-    fi
-    wlstate=$(cat /tmp/wlstate)
-    if [ ! $wlstate ]; then
-      /etc/init.d/wl1251-init start
-    fi
-    pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
-    for PID in $pidlist
-    do
-      kill -18 $PID #send SIGCONT
-    done
-    echo 255 > /sys/class/leds/pandora\:\:power/brightness #power LED bright
-    rm /tmp/powerstate
-  else
-    #in normal mode
-    echo 1 > /tmp/powerstate
-    cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed
-    cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
-    pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
-    for PID in $pidlist
-    do
-      kill -19 $PID #send SIGSTOP
-    done
-    rm /tmp/hcistate
-    hcistate=$(hciconfig hci0 | grep DOWN)
-    if [ $hcistate ]; then
-       echo "down" > /tmp/hcistate
-    else
-       hciconfig hci0 down
-    fi
-    rm /tmp/wlstate
-    wlstate=$(lsmod | grep -m1 wl1251)
-    if [ ! $wlstate ]; then
-       echo "down" > /tmp/wlstate
-    else
-           /etc/init.d/wl1251-init stop
-    fi
-    echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
-    echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
-    echo 16 > /sys/class/leds/pandora\:\:power/brightness #dim power LED
-    /usr/pandora/scripts/op_cpuspeed.sh 125
-  fi
-elif [ "$1" -ge "3" ]; then #button was pressed 3 sec or longer, shutdown
-  xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
-  time=5
-  countdown () {
-    for i in $(seq $time); do
-      precentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }')
-      echo $precentage
-      echo "# Shutdown in $(($time-$i))"
-      sleep 1
-    done
-  }
-  countdown  | su -c 'DISPLAY=:0.0  zenity --progress --auto-close --text "Shutdown in X" --title "Shutdown"' $xfceuser
-  if [ $? -eq 0 ]; then
-  shutdown -h now
-  else
-  su -c 'DISPLAY=:0.0  zenity --error --text "Shutdown aborted!"' $xfceuser
-  fi
-fi
-
diff --git a/testdata/scripts/pnd_hup.sh b/testdata/scripts/pnd_hup.sh
deleted file mode 100755 (executable)
index 9084f6d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-#HUP all apps who happen to look into one of the .desktop locations
-PIDS=$(lsof +d /usr/share/applications  /usr/local/share/applications/ /home/*/Desktop /home/*/.applications /home/*/.local/share/applications | awk '!/PID/ {print $2 }' | uniq)
-for pid in $PIDS; do
-        kill -HUP $pid
-done
diff --git a/testdata/scripts/pnd_make.sh b/testdata/scripts/pnd_make.sh
deleted file mode 100755 (executable)
index 3e8ad8b..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-######adjust path of genpxml.sh if you want to use that "feture"#####
-TEMP=`getopt -o p:d:x:i:c -- "$@"`
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
-eval set -- "$TEMP"
-while true ; do
-       case "$1" in
-               -p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;;
-               -d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;;
-               -x) echo "PXML set to $2" ;PXML=$2;shift 2 ;;
-               -i) echo "ICON set to $2" ;ICON=$2;shift 2 ;;
-               -c) echo "-c set, will create compressed squasfs image instead of iso $2" ;SQUASH=1;shift 1 ;;
-               --) shift ; break ;;
-               *) echo "Error while parsing arguments! $2" ; exit 1 ;;
-       esac
-done
-rnd=$RANDOM; # random number for genpxml and index$rnd.xml
-#generate pxml if guess or empty
-if [ ! $PXML ] || [ $PXML = "guess" ] && [  $PNDNAME ] && [ $FOLDER ];  then
-       PXMLtxt=$(/home/user/libpnd/pandora-libraries/testdata/scripts/genpxml.sh $FOLDER $ICON)
-       PXML=$FOLDER/PXML.xml
-       echo "$PXMLtxt" > $FOLDER/PXML.xml
-fi
-#check arguments
-if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then
-       echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x 
-       your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png"
-       exit 1
-fi
-if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists
-if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists
-#make iso from folder
-if [ ! $SQUASH ]; then
-        mkisofs -o $PNDNAME.iso -R $FOLDER
-else
-        if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') = 0 ]; then
-                echo "your squashfs version is older then version 4, pleas upgrade to 4.0 or later"
-                exit 1
-        fi
-        mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery
-fi
-#append pxml to iso
-cat $PNDNAME.iso $PXML >  $PNDNAME
-rm $PNDNAME.iso #cleanup
-#append icon if specified
-if [ $ICON ]; then # check if we want to add an icon
-       if [ ! -f $ICON ]; then #does the icon actually exist?
-               echo "$ICON doesnt exist"
-       else # yes
-       mv $PNDNAME $PNDNAME.tmp
-       cat $PNDNAME.tmp $ICON > $PNDNAME # append icon
-       rm $PNDNAME.tmp #cleanup
-       fi
-fi
-if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup
diff --git a/testdata/scripts/pnd_run.sh b/testdata/scripts/pnd_run.sh
deleted file mode 100644 (file)
index 0abee34..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-#!/bin/bash
-#Usage: pnd_run.sh -p your.pnd -e executeable [-a "(arguments)"] [ -s "cd to folder inside pnd"] [-b UID (name of mountpoint/pandora/appdata)] [-x close x before launching(script needs to be started with nohup for this to work]
-# -s startdir
-# arguments can be inside -e, -a is optional
-#/etc/sudoers needs to be adjusted if you touch any of the sudo lines
-# look at the comments in the nox part, adjust 
-#use "lsof /usr/lib/libX11.so.6 | awk '{print $1}'| sort | uniq > whitelist" with nothing running to generate the whitelist
-#todo - no proper order
-#validate params better
-#make uid/pnd_name mandatory (and rename var, its confusing!)
-#find a clean way of shutting down x without a fixed dm, mabye avoid nohup usage somehow
-#add options to just mount iso without union and to mount the union later
-#cleanup
-#Rewrite! - this sucks
-
-list_using_fs() {
-       for p in $(fuser -m $1 2>/dev/null);do ps hf $p;done
-}
-
-runApp() {
-       unset CURRENTSPEED
-       if ! [ -f "${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed" ]; then
-               if [ ${cpuspeed:-$(cat /proc/pandora/cpu_mhz_max)} -gt $(cat /proc/pandora/cpu_mhz_max) ]; then 
-                  cpuselection=$(zenity --title="set cpu speed" --height=350 --list --column "id" --column "Please select" --hide-column=1 --text="$PND_NAME suggests to set the cpu speed to $cpuspeed MHz to make it run properly.\n\n Do you want to change the cpu speed? (current speed: $(cat /proc/pandora/cpu_mhz_max) MHz)\n\nWarning: Setting the clock speed above 600MHz can be unstable and it NOT recommended!" "yes" "Yes, set it to $cpuspeed MHz" "custom" "Yes, select custom value" "yessave" "Yes, set it to $cpuspeed MHz and don't ask again" "customsave" "Yes, set it to custom speed and don't ask again" "no" "No, don't change the speed" "nosave" "No, don't chage the speed and don't ask again")
-                 if [ ${cpuselection} = "yes" ]; then  
-                       CURRENTSPEED=$(cat /proc/pandora/cpu_mhz_max)
-                       sudo /usr/pandora/scripts/op_cpuspeed.sh $cpuspeed
-                 elif [ ${cpuselection} = "custom" ]; then     
-                       CURRENTSPEED=$(cat /proc/pandora/cpu_mhz_max)
-                       sudo /usr/pandora/scripts/op_cpuspeed.sh
-                 elif [ ${cpuselection} = "customsave" ]; then 
-                       CURRENTSPEED=$(cat /proc/pandora/cpu_mhz_max)
-                       sudo /usr/pandora/scripts/op_cpuspeed.sh
-                       zenity --info --title="Note" --text="Speed saved.\n\nTo re-enable this dialogue, please delete the file\n${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed"
-                       cat /proc/pandora/cpu_mhz_max > ${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed
-                elif [ ${cpuselection} = "yessave" ]; then     
-                       CURRENTSPEED=$(cat /proc/pandora/cpu_mhz_max)
-                       cat /proc/pandora/cpu_mhz_max > /tmp/cpuspeed           
-                       zenity --info --title="Note" --text="Speed saved.\n\nTo re-enable this dialogue, please delete the file\n${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed"
-                       sudo /usr/pandora/scripts/op_cpuspeed.sh $cpuspeed
-                       cat /proc/pandora/cpu_mhz_max > ${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed
-                 elif [ ${cpuselection} = "nosave" ]; then                     
-                       zenity --info --title="Note" --text="Speed will not be changed.\n\nTo re-enable this dialogue, please delete the file\n${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed"
-                       echo 9999 > ${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed
-               fi
-              fi
-       else
-               cpuspeed=$(cat "${MOUNTPOINT}/pandora/appdata/${PND_NAME}/cpuspeed")
-               if [ "$cpuspeed" -lt "1500" ]; then
-                 CURRENTSPEED=$(cat /proc/pandora/cpu_mhz_max)
-                 echo Setting to CPU-Speed $cpuspeed MHz
-                 sudo /usr/pandora/scripts/op_cpuspeed.sh $cpuspeed
-               fi
-        fi
-
-       cd "/mnt/utmp/$PND_NAME"                # cd to union mount
-       if [ "$STARTDIR" ] && [ -d "$STARTDIR" ]; then
-               cd "$STARTDIR";                 # cd to folder specified by the optional arg -s
-       fi
-       echo "[------------------------------]{ App start }[---------------------------------]"
-       if [ -d /mnt/utmp/$PND_NAME/lib ];then
-               export LD_LIBRARY_PATH="/mnt/utmp/$PND_NAME/lib:${LD_LIBRARY_PATH:-"/usr/lib:/lib"}"
-       else
-               export LD_LIBRARY_PATH="/mnt/utmp/$PND_NAME:${LD_LIBRARY_PATH:-"/usr/lib:/lib"}"
-       fi
-       if [ -d /mnt/utmp/$PND_NAME/bin ];then
-               export PATH="/mnt/utmp/$PND_NAME/bin:${PATH:-"/usr/bin:/bin:/usr/local/bin"}"
-       fi
-       if [ -d /mnt/utmp/$PND_NAME/share ];then
-               export XDG_DATA_DIRS="/mnt/utmp/$PND_NAME/share:$XDG_DATA_DIRS:/usr/share"
-       fi
-       export XDG_CONFIG_HOME="/mnt/utmp/$PND_NAME"
-       "./$EXENAME" $ARGUMENTS
-                                               # execute app with ld_lib_path set to the union mount, a bit evil but i think its a good solution
-
-       #the app could have exited now, OR it went into bg, we still need to wait in that case till it really quits!
-       PID=$(pidof -o %PPID -x \"$EXENAME\")   # get pid of app
-       while [ "$PID" ];do                     # wait till we get no pid back for tha app, again a bit ugly, but it works
-               sleep 10s
-               PID=`pidof -o %PPID -x \"$EXENAME\"`
-       done
-       echo "[-------------------------------]{ App end }[----------------------------------]"
-
-       if [ ! -z "$CURRENTSPEED" ]; then
-               sudo /usr/pandora/scripts/op_cpuspeed.sh $CURRENTSPEED
-       fi
-}
-
-mountPnd() {
-       if [ $(id -u) -ne 0 ];then
-               echo "sudo /usr/pandora/scripts/pnd_run.sh -m $PNDARGS"
-               sudo /usr/pandora/scripts/pnd_run.sh -m $PNDARGS
-               mount | grep "on /mnt/utmp/${PND_NAME} type"
-               if [ $? -ne 0 ];then
-                       echo "The Union File-system is not mounted !"
-                       return 1
-               fi
-               return $?
-       fi
-       #create mountpoints, check if they exist already first to avoid annoying error messages
-       if ! [ -d "/mnt/pnd/${PND_NAME}" ]; then 
-               mkdir -p "/mnt/pnd/${PND_NAME}"         #mountpoint for iso, ro
-       fi 
-       #writeable dir for union
-       if ! [ -d "${APPDATADIR}" ]; then 
-               mkdir -p "${APPDATADIR}"
-               chmod -R a+xrw "${APPDATADIR}" 2>/dev/null
-       fi
-       # create the union mountpoint
-       if ! [ -d "/mnt/utmp/${PND_NAME}" ]; then
-               mkdir -p "/mnt/utmp/${PND_NAME}"                # union over the two
-       fi
-       #is the union already mounted? if not mount evrything, else launch the stuff
-       mount | grep "on /mnt/utmp/${PND_NAME} type"
-       if [ $? -ne 0 ];then
-               mount | grep "on /mnt/pnd/${PND_NAME} type"
-               if [ $? -ne 0 ];then
-                       echo not mounted on loop yet, doing so
-                       #check if pnd is already attached to loop 
-                       LOOP=$(losetup -a | grep "$PND" | tail -n1 | awk -F: '{print $1}')
-                       #check if the loop device is already mounted
-                       if ! [ -z "$LOOP" ];then
-                               echo "Found a loop ($LOOP), using it"
-                               loopmountedon=$( mount | grep "$(mount | grep "$LOOP" | awk '{print $3}')" | grep utmp | awk '{print $3}' )
-                       else
-                               loopmountedon=""
-                       fi
-                       echo "LoopMountedon: $loopmountedon"
-                       if [ ! "$loopmountedon" ]; then #check if the pnd is already attached to some loop device but not used
-                               FREELOOP=$LOOP 
-                               #reuse existing loop
-                               if [ ! "$LOOP" ]; then
-                                       FREELOOP=$(/sbin/losetup -f) #get first free loop device
-                                       echo $FREELOOP
-                                       if [ ! "$FREELOOP" ]; then  # no free loop device, create a new one
-                                                   #find a free loop device and use it 
-                                                   usedminor=$(/sbin/losetup -a | tail -n1)
-                                                   usedminor=${usedminor:9:1}
-                                                   echo usedminor $usedminor
-                                                   freeminor=$(($usedminor+1))
-                                                   echo freeminor $freeminor
-                                                   mknod -m777 /dev/loop$freeminor b 7 $freeminor
-                                                   FREELOOP=/dev/loop$freeminor
-                                       fi
-                               fi
-                               #detect fs
-
-                               case $PND_FSTYPE in
-                               ISO)
-                                       /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
-                                       mntline="mount" #setup the mountline for later
-                                       mntdev="${FREELOOP}"
-                                       #mntline="mount -o loop,mode=777 $PND /mnt/pnd/$PND_NAME"
-                                       echo "Filetype is $PND_FSTYPE";;
-                               directory)
-                                       #we bind the folder, now it can be treated in a unified way 
-                                       #ATENTION: -o ro doesnt work for --bind at least on 25, on 26 its possible using remount, may have changed on 27
-                                       mntline="mount --bind -o ro"
-                                       mntdev="${PND}"
-                                       echo "Filetype is $PND_FSTYPE";;
-                               Squashfs)
-                                       /sbin/losetup $FREELOOP "$PND" #attach the pnd to the loop device
-                                       mntline="mount -t squashfs"
-                                       mntdev="${FREELOOP}"
-                                       echo "Filetype is $PND_FSTYPE";;
-                               *)
-                                       echo "error determining fs, output was $PND_FSTYPE"
-                                       exit 1;;
-                               esac
-                               echo "Mounting PND ($mntline) :"
-                               $mntline "$mntdev" "/mnt/pnd/${PND_NAME}" #mount the pnd/folder
-
-                       else #the pnd is already mounted but a mount was requested with a different basename/uid, just link it there
-                                     echo $LOOP already mounted on $loopmountedon skipping losetup - putting link to old mount
-                                     #this is bullshit
-                                     rmdir "/mnt/utmp/$PND_NAME"
-                                     ln -s $loopmountedon "/mnt/utmp/$PND_NAME" 
-                       fi
-
-                       mount | grep "on /mnt/pnd/${PND_NAME} type"
-                       if [ $? -ne 0 ];then
-                               echo "The PND File-system is not mounted ! - Union wont work anyway"
-                               return 2
-                       fi
-               
-               else
-                       echo "the PND is already mounted"
-               fi
-               FILESYSTEM=$(mount | grep "on $MOUNTPOINT " | grep -v rootfs | awk '{print $5}' | tail -n1) #get filesystem appdata is on to determine aufs options
-               RO=0;for o in $(mount|grep "on $MOUNTPOINT "|sed 's/.*(//;s/)$//;s/,/ /g');do [[ $o = "ro" ]]&& RO=1;done
-               if [ $RO -eq 1 ];then
-                       echo "SD-Card is mounted Read-only !! Trying to remount RW"
-                       mount -oremount,rw $MOUNTPOINT
-               fi
-               echo "Filesystem is $FILESYSTEM"
-               echo "Mounting the Union FS using ${APPDATADIR} as Write directory:"
-               if [[ "$FILESYSTEM" = "vfat" ]]; then # use noplink on fat, dont on other fs's 
-                       #append is fucking dirty, need to clean that up
-                       echo mount -t aufs -o exec,noplink,dirs="${APPDATADIR}=rw+nolwh":"/mnt/pnd/$PND_NAME=rr$append" none "/mnt/utmp/$PND_NAME"
-                       mount -t aufs -o exec,noplink,dirs="${APPDATADIR}=rw+nolwh":"/mnt/pnd/$PND_NAME=rr$append" none "/mnt/utmp/$PND_NAME"
-                       # put union on top
-               else
-                       mount -t aufs -o exec,dirs="${APPDATADIR}=rw+nolwh":"/mnt/pnd/$PND_NAME=rr$append" none "/mnt/utmp/$PND_NAME" 
-                       # put union on top
-               fi
-
-               mount | grep "on /mnt/utmp/${PND_NAME} type"
-               if [ $? -ne 0 ];then
-                       echo "The Union File-system is not mounted !"
-                       return 1
-               fi
-               
-       else
-               echo "Union already mounted"
-       fi
-}
-
-cleanups() {
-       #delete folders created by aufs if empty
-       rmdir -rf "${APPDATADIR}/.wh..wh.plnk" 2>/dev/null
-       rmdir -rf "${APPDATADIR}/.wh..wh..tmp" 2>/dev/null
-       rmdir "${APPDATADIR}/.wh..wh.orph" 2>/dev/null
-       rm "${APPDATADIR}/.aufs.xino" 2>/dev/null
-
-       #delete appdata folder and ancestors if _empty_
-       rmdir -p "${APPDATADIR}" 2>/dev/null
-
-       # Clean the loopback device
-       if [ $PND_FSTYPE = ISO ] || [ $PND_FSTYPE = Squashfs ]; then # check if we where running an iso, clean up loop device if we did
-               LOOP=$(losetup -a | grep "$(basename $PND)" | tail -n1 | awk -F: '{print $1}')
-               /sbin/losetup -d $LOOP
-               rm $LOOP
-       fi
-
-       echo cleanup done
-}
-
-umountPnd() {
-       if mount | grep -q "on /mnt/pnd/${PND_NAME} type";then
-               umount "/mnt/pnd/$PND_NAME"
-       fi
-       if ! [ -z "$(mount |grep pnd/$PND_NAME|cut -f3 -d' ')" ]; then
-               echo umount PND failed, didnt clean up. Process still using this FS :
-               list_using_fs "/mnt/pnd/$PND_NAME"
-       else
-               # removing the now useless mountpoint
-               if [ -d /mnt/pnd/$PND_NAME ];then
-                       rmdir "/mnt/pnd/$PND_NAME"
-               fi
-
-               # All went well, cleaning
-               cleanups
-       fi
-}
-
-umountUnion() {
-       # Are we root yet ?
-       if [ $(id -u) -ne 0 ];then
-               sudo /usr/pandora/scripts/pnd_run.sh -u $PNDARGS
-               return $?
-       fi
-
-       # Make sure the Union FS is unmounted
-       if mount | grep -q "on /mnt/utmp/${PND_NAME} type";then
-               umount "/mnt/utmp/$PND_NAME" #umount union
-       fi
-       if ! [ -z "$(mount |grep utmp/$PND_NAME|cut -f3 -d' ')" ]; then
-               echo umount UNION failed, didnt clean up. Process still using this FS :
-               list_using_fs "/mnt/utmp/$PND_NAME"
-       else
-               # the Union is umounted, removing the now empty mountpoint
-               if [ -d "/mnt/utmp/$PND_NAME" ];then
-                       rmdir "/mnt/utmp/$PND_NAME"
-               elif [ -e "/mnt/utmp/$PND_NAME" ];then
-                       rm "/mnt/utmp/$PND_NAME" >/dev/null 2>&1 # as it might be a symlink
-               fi
-               # Try umounting the PND
-               umountPnd
-       fi
-}
-
-main() {
-       if [ $nox ]; then #the app doesnt want x to run, so we kill it and restart it once the app quits
-               if [ ! $(pidof X) ]; then 
-                       unset $nox
-               else
-                       applist=$(lsof /usr/lib/libX11.so.6 | awk '{print $1}'| sort | uniq)
-                       whitelist=$(cat ~/pndtest/whitelist) #adjust this to a fixed whitelist, maybe in the config dir
-                       filteredlist=$(echo -e "$applist\n\n$whitelist\n\n$whitelist" | sort | uniq -u) #whitelist appended two times so those items are always removed
-                       if [ ${#filteredlist} -ge 1 ]; then
-                               message=$(echo -e "The following applications are still running, are you sure you want to close x? \n$filteredlist")
-                               echo -e "?ae[34me[30m?"
-                               xmessage -center "$message", -buttons yes,no
-                               if [ $? = 102 ]; then
-                                       exit 1
-                               fi
-                               sudo /etc/init.d/slim-init stop
-                               sleep 5s
-                       else
-                               echo -e "?ae[34me[30m?"
-                               xmessage -center "killing x, nothing of value will be lost", -buttons ok,cancel
-                               if [ $? = 102 ]; then
-                                       exit 1
-                               fi
-                               # close x now, do we want to use slim stop or just kill x?
-                               sudo /etc/init.d/slim-init stop
-                               sleep 5s
-                       fi
-               fi
-       fi
-
-       case $ACTION in
-       mount)  mountPnd;;
-       umount) umountUnion;;
-       run)
-               mountPnd
-               if [ $? -ne 0 ];then
-                       zenity --warning --title="Mounting the PND failed" --text="Mounting the PND failed. The application wont start. Please have a look at $LOGFILE"
-                       return 3
-               fi
-               oPWD=$(pwd)
-               runApp
-               cd $oPWD
-               umountUnion;;
-       esac
-
-
-       if [ $nox ]; then #restart x if it was killed
-               echo "starting x in 5s"
-               sleep 5
-               sudo /etc/init.d/slim-init start
-       fi
-}
-
-showHelp() {
-       cat <<endHELP
-Usage: pnd_run.sh -p your.pnd -e executeable [-a "(arguments)"] [ -s "cd to folder inside pnd"] [-b UID (name of mountpoint/pandora/appdata)] [-x close x before launching(script needs to be started with nohup for this to work]
-Usage for mounting/umounting pnd_run.sh -p your.pnd -b uid -m or -u
-endHELP
-}
-
-function parseArgs() {
-ACTION=run
-TEMP=`getopt -o d:p:e:a:b:s:m::u::n::x::j:c: -- "$@"`
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
-# Note the quotes around `$TEMP': they are essential!
-eval set -- "$TEMP"
-while true ; do
-        case "$1" in
-                -p) PND="$2";shift 2;;
-                -e) EXENAME="$2";shift 2 ;;
-                -b) PND_NAME="$2";shift 2;;
-                -s) STARTDIR="$2";shift 2;;
-                -m) ACTION=mount;shift 2;;
-                -u) ACTION=umount;shift 2;;
-                -x) nox=1;shift 2;;
-                -j) append="$2";shift 2;;
-                -c) cpuspeed="$2";shift 2;;
-                -d) APPDATASET=1;APPDATADIR="$2";shift 2;;
-                -a)
-                        case "$2" in
-                                "") echo "no arguments"; shift 2 ;;
-                                *) ARGUMENTS="$2";shift 2 ;;
-                        esac ;;
-                --) shift ; break ;;
-                *) echo "Error while parsing arguments!"; showHelp; exit 1 ;;
-        esac
-done
-}
-######################################################################################
-####   Main :
-##
-PNDARGS="$@"
-parseArgs "$@"
-
-#PND_NAME really should be something sensible and somewhat unique
-#if -b is set use that as pnd_name, else generate it from PND
-#get basename (strip extension if file) for union mountpoints etc, maybe  this should be changed to something specified inside the xml
-#this should probably be changed to .... something more sensible
-#currently only everything up to the first '.' inside the filenames is used.
-PND_NAME=${PND_NAME:-"$(basename $PND | cut -d'.' -f1)"}
-
-if [ ! -e "$PND" ]; then #check if theres a pnd suplied, need to clean that up a bit more
-       echo "ERROR: selected PND($PND) file does not exist!"
-       showHelp
-       exit 1
-fi
-
-if [ ! "$EXENAME" ] && [[ "$ACTION" = "run" ]]; then
-       echo "ERROR: no executable name provided!"
-       showHelp
-       exit 1
-fi
-
-PND_FSTYPE=$(file -b "$PND" | awk '{ print $1 }')      # is -p a zip/iso or folder?
-MOUNTPOINT=$(df "$PND" | tail -1|awk '{print $6}')     # find out on which mountpoint the pnd is
-if [ $(df "$PND"|wc -l) -eq 1 ];then                   # this is actually a bug in busybox
-       MOUNTPOINT="/";
-elif [ ! -d "$MOUNTPOINT" ]; then 
-       MOUNTPOINT="";
-fi
-
-[ ! -z $APPDATASET ] || [ -z ${MOUNTPOINT} ] && APPDATADIR=${APPDATADIR:-$(dirname $PND)/$PND_NAME}
-APPDATADIR=${APPDATADIR:-${MOUNTPOINT}/pandora/appdata/${PND_NAME}}
-
-LOGFILE="/tmp/pndrun_${PND_NAME}.out"
-
-if [[ $ACTION != "run" ]];then #not logging mount and umount as these are from command-line
-       main
-elif [ $nox ]; then
-       main > $LOGFILE 2>&1 & 
-       disown
-else
-       main > $LOGFILE 2>&1
-fi
-