X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=appify.git;a=blobdiff_plain;f=appify.sh;h=c7ffa8e2a1fc67cdc1e520eadcb7547c697f0872;hp=d0bb922e50b1d3815e726c67d95abbcb9aeac5c1;hb=HEAD;hpb=cba127afa75bbac8d833e0051fa9a56b714bbdef diff --git a/appify.sh b/appify.sh index d0bb922..c7ffa8e 100755 --- a/appify.sh +++ b/appify.sh @@ -1,7 +1,9 @@ #!/bin/bash # -# appify -- convert your non-interactive shell script into a Mac OS X application +# appify -- convert non-interactive shell script into Mac OS X applications # Copyright (C) 2010 Adam Backstrom +# Copyright (C) 2015 Alexander Barton +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -19,7 +21,7 @@ args=$(getopt h $*) function usage { - echo "Usage: $0 [-h] script.sh target.app" + echo "Usage: $0 [-h] []" exit 2 } @@ -36,17 +38,28 @@ for i ; do esac done -if [ $# != 2 ]; then +if [ $# -lt 2 -o $# -gt 3 ]; then usage fi SCRIPT=$1 TARGET=$2 +ICON=$3 BASENAME=`basename "$SCRIPT"` +if [ ! -r "$SCRIPT" ]; then + echo "$SCRIPT isn't readable!" 1>&2 + exit 3 +fi + if [ -e "$TARGET" ]; then - echo "$TARGET exists, exiting" 1>&2 + echo "$TARGET exists!" 1>&2 + exit 3 +fi + +if [ -n "$ICON" -a ! -r "$ICON" ]; then + echo "$ICON isn't readable!" 1>&2 exit 3 fi @@ -83,6 +96,17 @@ cat <"$TARGET/Contents/Info.plist" ???? CFBundleVersion 1.0 +EOF + +if [ -n "$ICON" ]; then + cat <>"$TARGET/Contents/Info.plist" + CFBundleIconFile + app.icns +EOF + cp "$ICON" "$TARGET/Contents/Resources/app.icns" || exit 1 +fi + +cat <>"$TARGET/Contents/Info.plist" EOF