Skip to content

Instantly share code, notes, and snippets.

@duffyjp
Last active February 16, 2022 17:11
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 duffyjp/13a8f7a40cb4e43a240811c64235b25b to your computer and use it in GitHub Desktop.
Save duffyjp/13a8f7a40cb4e43a240811c64235b25b to your computer and use it in GitHub Desktop.
Script to open Chrome in app mode and resize to 1024x768 (Mac / Linux)
#!/bin/bash
url=${1:-http://localhost:3000}
# FYI: If your URL has an & you need to pass the argument in quotes.
# Chrome app mode doesn't work without the http/https part.
if [[ $url = *"http"* ]]; then
echo $url
else
url="http://${url}"
echo $url
fi
# Hack to resize the window to 1024x768.
# This causes Chrome to just exit now... /shrug
# url="data:text/html,<script>window.moveTo(0,0);window.resizeTo(1024,768);window.location='${url}';</script>"
# Launch Chrome from one of it's usual locations.
if [ -e "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=$url 2>/dev/null
elif [ -e "~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
~/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=$url 2>/dev/null
else
/usr/bin/google-chrome --app=$url 2>/dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment