Skip to content

Instantly share code, notes, and snippets.

@jffry
Forked from demonbane/makeapp.sh
Last active June 19, 2016 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jffry/239833b8f3598ebc6e03 to your computer and use it in GitHub Desktop.
Save jffry/239833b8f3598ebc6e03 to your computer and use it in GitHub Desktop.
Create a wrapped app launcher for Noisli using Chrome on OSX

If you are on OSX and have Chrome installed, you can use it to wrap apps so that they have their own app icon.

To quickly install it, download and run the script, or just open a terminal and run this command:

curl https://gist.githubusercontent.com/jffry/239833b8f3598ebc6e03/raw/make-noisli-app.sh | bash

That will automatically install the app and run it, though subsequently it's like a normal OSX app and you don't need to run this script again.

#!/bin/sh
#this script adapted from the excellent https://gist.github.com/demonbane/1065791
set -e
name="Netflix"
url="https://www.netflix.com/browse"
icon="$(pwd)/netflix-icon.tmp.png"
size="1000x750"
# write the icon
curl --silent http://i.imgur.com/y0Yuhfo.png > $icon
# If you've got Chrome you're good to go
chromePath="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
appRoot="/Applications"
# various paths used when creating the app
resourcePath="$appRoot/$name.app/Contents/Resources"
execPath="$appRoot/$name.app/Contents/MacOS"
profilePath="$appRoot/$name.app/Contents/Profile"
plistPath="$appRoot/$name.app/Contents/Info.plist"
# make the directories
mkdir -p "$resourcePath" "$execPath" "$profilePath"
# convert the icon and copy into Resources
if [ -f "$icon" ] ; then
sips -s format tiff "$icon" --out "$resourcePath/icon.tiff" --resampleHeightWidth 128 128 >& /dev/null
tiff2icns -noLarge "$resourcePath/icon.tiff" >& /dev/null
fi
# create the executable
cat >"$execPath/$name" <<EOF
#!/bin/sh
exec "$chromePath" --app="$url" --no-default-browser-check --no-first-run --window-size=$size --user-data-dir="$profilePath" "\$@"
EOF
chmod +x "$execPath/$name"
# create the Info.plist
cat > "$plistPath" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>CFBundleExecutable</key>
<string>$name</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
</plist>
EOF
# create a profile
#clean up
rm -f $icon &> /dev/null\
# Launch it
open "$appRoot/$name.app"
#!/bin/sh
#this script adapted from the excellent https://gist.github.com/demonbane/1065791
set -e
name="Noisli"
url="http://www.noisli.com/"
icon="$(pwd)/noisli-icon.tmp.png"
size="1000x750"
# write the icon
curl --silent http://www.noisli.com/assets/noisli-app-icon.png > $icon
# If you've got Chrome you're good to go
chromePath="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
appRoot="/Applications"
# various paths used when creating the app
resourcePath="$appRoot/$name.app/Contents/Resources"
execPath="$appRoot/$name.app/Contents/MacOS"
profilePath="$appRoot/$name.app/Contents/Profile"
plistPath="$appRoot/$name.app/Contents/Info.plist"
# make the directories
mkdir -p "$resourcePath" "$execPath" "$profilePath"
# convert the icon and copy into Resources
if [ -f "$icon" ] ; then
sips -s format tiff "$icon" --out "$resourcePath/icon.tiff" --resampleHeightWidth 128 128 >& /dev/null
tiff2icns -noLarge "$resourcePath/icon.tiff" >& /dev/null
fi
# create the executable
cat >"$execPath/$name" <<EOF
#!/bin/sh
exec "$chromePath" --app="$url" --no-default-browser-check --no-first-run --window-size=$size --user-data-dir="$profilePath" "\$@"
EOF
chmod +x "$execPath/$name"
# create the Info.plist
cat > "$plistPath" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>CFBundleExecutable</key>
<string>$name</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
</plist>
EOF
# create a profile
#clean up
rm -f $icon &> /dev/null\
# Launch it
open "$appRoot/$name.app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment