#! /usr/bin/env bash # Create a Chrome-based Single Site Browser OSX App for a specific URL. # # Credit: Borrowed from somewhere and then fixed/improved by @jimeh. name="$1" url="$2" icon="$3" if [ -z "$name" ] || [ -z "$url" ]; then echo 'usage: make-chrome-ssb-for-osx "Google Music"' \ '"https://play.google.com/music"' exit 1 fi chrome_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" if [ ! -f "$chrome_path" ]; then echo "ERROR: Chrome not found."; exit 1; fi app_path="/Applications/${name}.app" if [ -d "$app_path" ]; then echo "ERROR: \"${app_path}\" exits."; exit 1; fi # Various paths used when creating the app. resource_dir="${app_path}/Contents/Resources" exec_dir="${app_path}/Contents/MacOS" exec_file="${exec_dir}/${name//[[:space:]]}" plist_file="${app_path}/Contents/Info.plist" app_support="${HOME}/Library/Application Support" profile_dir="${app_support}/me.jimeh.chrome-ssb/Apps/${name}" bundle_identifier="me.jimeh.chrome-ssb.${name}" # Create the directories. mkdir -p "$resource_dir" "$exec_dir" "$profile_dir" # convert the icon and copy into Resources if [ -f "$icon" ] ; then sips -s format tiff "$icon" \ --out "${resource_dir}/icon.tiff" \ --resampleWidth 128 >& /dev/null tiff2icns -noLarge "${resource_dir}/icon.tiff" >& /dev/null if [ -f "${resource_dir}/icon.tiff" ]; then rm "${resource_dir}/icon.tiff" fi fi # Create the executable. cat > "$exec_file" < "$plist_file" < CFBundleExecutable $(basename "$exec_file") CFBundleIdentifier ${bundle_identifier} CFBundleIconFile icon.icns EOF