Last active
August 29, 2015 14:22
-
-
Save jhildensperger/8b1e71eaf3566ec951b9 to your computer and use it in GitHub Desktop.
make a chrome app from FB Messenger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run | |
# curl -o $TMPDIR/make_fb_messenger_app.sh 'https://gist.githubusercontent.com/jhildensperger/8b1e71eaf3566ec951b9/raw/52f02d049dd25a987b2cb33e092f3882fc256bab/make_fb_messenger_app.sh' && \ | |
# chmod +x $TMPDIR/make_fb_messenger_app.sh && \ | |
# $TMPDIR/make_fb_messenger_app.sh | |
#!/bin/sh | |
chromeAppPath="/Applications/Google Chrome.app" | |
chromeExecutablePath="$chromeAppPath/Contents/MacOS/Google Chrome" | |
if [ -d "$chromeAppPath" ]; then | |
curl -o $TMPDIR/icon.png 'https://scontent.fsjc1-1.fna.fbcdn.net/hphotos-xpf1/t39.2365-6/11057099_383365451847896_1818480781_n.png' | |
appName="FB Messenger" | |
appUrl="https://www.messenger.com" | |
iconPath="$TMPDIR/icon.png" | |
# various paths used when creating the app | |
resourcePath="/Applications/$appName.app/Contents/Resources" | |
execPath="/Applications/$appName.app/Contents/MacOS" | |
profilePath="/Applications/$appName.app/Contents/Profile" | |
plistPath="/Applications/$appName.app/Contents/Info.plist" | |
# make the directories | |
mkdir -p "$resourcePath" "$execPath" "$profilePath" | |
# convert the icon and copy into Resources | |
if [ -f $iconPath ] ; then | |
sips -s format tiff $iconPath --out "$resourcePath"/icon.tiff --resampleWidth 128 >& /dev/null | |
tiff2icns -noLarge "$resourcePath"/icon.tiff >& /dev/null | |
fi | |
# create the executable | |
cat >"$execPath"/"$appName" <<EOF | |
#!/bin/sh | |
exec "$chromeExecutablePath" --app="$appUrl" --user-data-dir="$profilePath" "\$@" | |
EOF | |
chmod +x "$execPath"/"$appName" | |
# 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>$appName</string> | |
<key>CFBundleIconFile</key> | |
<string>icon</string> | |
</dict> | |
</plist> | |
EOF | |
echo "FB Messenger has been installed in your Applications directory" | |
echo "launching application" | |
open "/Applications/$appName.app/" | |
exit 0 | |
else | |
echo "You must have the Chrome App installed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment