~mozillateam/prism/prism

1 by Fabien Tassin
* Initial release based on WebRunner 0.07 SVN 20070925r7025
1
#!/bin/sh
2
84 by Fabien Tassin
* New packaging using cdbs and the new xulapp build-system
3
# Copyright (c) 2007-2008 Fabien Tassin <fta@sofaraway.org>
4
# Description: Prism helper
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License as
8
# published by the Free Software Foundation; either version 2, or (at
9
# your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with this program; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1 by Fabien Tassin
* Initial release based on WebRunner 0.07 SVN 20070925r7025
19
84 by Fabien Tassin
* New packaging using cdbs and the new xulapp build-system
20
PRISM=/usr/bin/prism-bin
46 by Fabien Tassin
* Move everything out of /usr/lib to /usr/share as it's an all arch package
21
WEBRUNNER=/usr/share/prism
30 by Fabien Tassin
* Install webapps in /usr/share/prism/apps to avoid mixup
22
WEBAPPDIR=/usr/share/prism/apps
1 by Fabien Tassin
* Initial release based on WebRunner 0.07 SVN 20070925r7025
23
24
if [ "$1" = "-d" ] ; then
25
  DEBUG="-console -jsconsole"
26
  shift
27
fi
28
31 by Fabien Tassin
* Fix startup script not using the proper syntax when called from nautilus
29
if [ "Z$1" != Z ] && [ "`echo $1 | sed -e 's/.*\.//'`" = "webapp" ] ; then
30
  WEBAPP=`echo $1 | sed -e 's,^file://,,'`
67 by Fabien Tassin
* Prevent webapps to be unpacked at each run so user data is now
31
  FILE=$WEBAPP
1 by Fabien Tassin
* Initial release based on WebRunner 0.07 SVN 20070925r7025
32
else
31 by Fabien Tassin
* Fix startup script not using the proper syntax when called from nautilus
33
  APPNAME=`basename $0 | sed -e 's/\.sh$//; s/prism-//'`
34
  if [ -f $WEBAPPDIR/$APPNAME.webapp ] ; then
67 by Fabien Tassin
* Prevent webapps to be unpacked at each run so user data is now
35
    FILE=$WEBAPPDIR/$APPNAME.webapp
31 by Fabien Tassin
* Fix startup script not using the proper syntax when called from nautilus
36
  else
36 by Fabien Tassin
* Fix default prism action no longer launching the Desktop UI
37
    ARGS=$@
31 by Fabien Tassin
* Fix startup script not using the proper syntax when called from nautilus
38
  fi
1 by Fabien Tassin
* Initial release based on WebRunner 0.07 SVN 20070925r7025
39
fi
40
67 by Fabien Tassin
* Prevent webapps to be unpacked at each run so user data is now
41
if [ "Z$FILE" != "Z" ] ; then
42
  # If this webapp has already been extracted, run it by its id rather than
43
  # by its filename that unpacks it at each run.
44
  # It's important to preserve the json file for window size and position.
45
  ARGS="-webapp $FILE"
46
  if [ -f $FILE ] ; then
69 by Fabien Tassin
* Handle \r in webapp.ini when finding webapp IDs
47
    ID=`unzip -p $FILE webapp.ini | grep ^id= | cut -d= -f2 | tr -d '\r'`
84 by Fabien Tassin
* New packaging using cdbs and the new xulapp build-system
48
    DIR=$HOME/.webapps/$ID
49
    if [ -d $DIR ] ; then # The webapp already exists.
50
      # Check for the png icon.
51
      WNAME=`grep -E '^icon=' $DIR/webapp.ini | cut -d= -f2 | tr -d '\r'`
52
      if [ ! -f $DIR/icons/default/$WNAME.png ] ; then
53
        ( cd $DIR/icons/default ; unzip $FILE $WNAME.png )
54
      fi
55
      ARGS="-webapp $ID"
56
      # Check for an override.ini file
85 by Fabien Tassin
* Patch webapps to include to ship an override.ini file allowing each webapp
57
      if [ ! -f $DIR/override.ini ] ; then
58
        ANAME=`grep -E '^name=' $DIR/webapp.ini | cut -d= -f2 | tr -d '\r'`
59
	if [ "Z$ANAME" != Z ] ; then
60
          printf "[App]\nVendor=Prism\nName=$ANAME" > $DIR/override.ini
61
          ARGS="-override $DIR/override.ini $ARGS"
62
	else
90 by Fabien Tassin
* Really fix the missing 'name' field previously missed when there
63
          # Add missing 'name' based on 'id'
64
          ANAME=`echo $ID | sed -e 's/@.*//'`
65
          echo "name=$ANAME" >> $DIR/webapp.ini
66
	  ARGS="-no-remote $ARGS"
85 by Fabien Tassin
* Patch webapps to include to ship an override.ini file allowing each webapp
67
        fi
68
      else
69
        ARGS="-override $DIR/override.ini $ARGS"
67 by Fabien Tassin
* Prevent webapps to be unpacked at each run so user data is now
70
      fi
71
    fi
84 by Fabien Tassin
* New packaging using cdbs and the new xulapp build-system
72
  else
73
    echo "Error: can't find $FILE"
74
    exit 1
67 by Fabien Tassin
* Prevent webapps to be unpacked at each run so user data is now
75
  fi
76
fi
77
84 by Fabien Tassin
* New packaging using cdbs and the new xulapp build-system
78
exec $PRISM $DEBUG $ARGS