Last active
February 16, 2022 17:11
-
-
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)
This file contains hidden or 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
#!/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