]> arthur.barton.de Git - appify.git/commitdiff
New option to add an icon to the application bundle master
authorAlexander Barton <alex@barton.de>
Wed, 8 Apr 2015 12:04:06 +0000 (14:04 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 8 Apr 2015 12:04:06 +0000 (14:04 +0200)
appify.sh

index a7db78620f05e361fbf60059f9aff50c0beaf282..c7ffa8e2a1fc67cdc1e520eadcb7547c697f0872 100755 (executable)
--- a/appify.sh
+++ b/appify.sh
@@ -21,7 +21,7 @@
 args=$(getopt h $*)
 
 function usage {
 args=$(getopt h $*)
 
 function usage {
-    echo "Usage: $0 [-h] <script.sh> <target.app>"
+    echo "Usage: $0 [-h] <script.sh> <target.app> [<icons.icns>]"
     exit 2
 }
 
     exit 2
 }
 
@@ -38,12 +38,13 @@ for i ; do
     esac
 done
 
     esac
 done
 
-if [ $# != 2 ]; then
+if [ $# -lt 2 -o $# -gt 3 ]; then
     usage
 fi
 
 SCRIPT=$1
 TARGET=$2
     usage
 fi
 
 SCRIPT=$1
 TARGET=$2
+ICON=$3
 
 BASENAME=`basename "$SCRIPT"`
 
 
 BASENAME=`basename "$SCRIPT"`
 
@@ -57,6 +58,11 @@ if [ -e "$TARGET" ]; then
     exit 3
 fi
 
     exit 3
 fi
 
+if [ -n "$ICON" -a ! -r "$ICON" ]; then
+    echo "$ICON isn't readable!" 1>&2
+    exit 3
+fi
+
 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
 
 if [ $SCRIPTSIZE -lt 28 ]; then
 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
 
 if [ $SCRIPTSIZE -lt 28 ]; then
@@ -90,6 +96,17 @@ cat <<EOF >"$TARGET/Contents/Info.plist"
     <string>????</string>
     <key>CFBundleVersion</key>
     <string>1.0</string>
     <string>????</string>
     <key>CFBundleVersion</key>
     <string>1.0</string>
+EOF
+
+if [ -n "$ICON" ]; then
+    cat <<EOF >>"$TARGET/Contents/Info.plist"
+    <key>CFBundleIconFile</key>
+    <string>app.icns</string>
+EOF
+    cp "$ICON" "$TARGET/Contents/Resources/app.icns" || exit 1
+fi
+
+cat <<EOF >>"$TARGET/Contents/Info.plist"
 </dict>
 </plist>
 EOF
 </dict>
 </plist>
 EOF