Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A small App that starts Vivaldi for Mac in such a way that it will store its profile within a subfolder (Useful for testing)

Vivaldi "Standalone Mode" on Mac

The following commands will produce a small application that allows you to run Vivaldi—or any other Chromium-based browser—in Standalone mode on a Mac. This could be used for testing a specific setup or version, without touching the system wide settings (profile). It can also be used to create a portable (USB install) of Vivaldi that you could store on an external disk, for sharing between computers.

Manual method

Start Terminal and issue the following:

mkdir -p Standalone\ Mode.app/Contents/MacOS
printf '#!/bin/sh\nopen -a "${0%%/*.app/*}"/[!\(Standalone\)]*.app --args --user-data-dir="${0%%/*.app/*}/profile"\n' > Standalone\ Mode.app/Contents/MacOS/Standalone\ Mode
chmod +x Standalone\ Mode.app/Contents/MacOS/Standalone\ Mode

You should now have an application called "Standalone Mode", stored in the folder where Terminal is running—you can check the folder location with pwd or open the folder in Finder with open .

Make a new, empty folder and place "Standalone Mode" and "Vivaldi" inside—nothing else.

To use, simply double click on "Standalone Mode", rather than running Vivaldi directly. Your settings will be stored in a subfolder called "profile".

Automated unpacking and standalone setup

For those users who use the Terminal frequently, I have included a shell script that can be used to automate unpacking a Vivaldi .dmg package into an appropriately named directory. This will also set up a "Standalone Mode" launcher application for you.

Setup

  • Download vivaldi-standalone.sh either by cloning this git repository or by clicking on the Raw link (below) in your browser.
  • Make the script executable and move it to a suitable location:
chmod +x vivaldi-standalone.sh
sudo mv vivaldi-standalone.sh /usr/local/bin/vivaldi-standalone

Usage

Issue the following (adjust "Vivaldi.1.0.365.3.dmg" to be the name and location of the Vivaldi .dmg you are setting up):

vivaldi-standalone Vivaldi.1.0.365.3.dmg

You will be prompted to agree to the Vivaldi license—scroll down by pressing Space several times, then press Y and Enter to agree.

To run Vivaldi, navigate into the newly created directory, and double click on "Standalone Mode"—always use this rather than running Vivaldi directly. Your settings will be stored in a subfolder called "profile".

#!/bin/sh
# Check that the user specified a Vivaldi package to extract from
if [ -z "$1" ]; then
echo "You must specify a Vivaldi .dmg e.g." >&2
echo " $ `basename $0` Vivaldi.1.0.365.3.dmg" >&2
exit 1
fi
# Check the package has an appropriate name
if ! echo "$1" | grep -q '[Vv]ivaldi.*\.dmg$'; then
echo "$1 is not named like a Vivaldi Mac package" >&2
exit 1
fi
# Check that the package is readable
if [ ! -r "$1" ]; then
echo "$1 is either not present or cannot be read" >&2
exit 1
fi
# Extract the Vivaldi version number from the package name
VNUM=$(echo "$1" | sed -E 's/.*(([0-9]+\.){3}[0-9]+).*/\1/')
if [ -z "$VNUM" ]; then
echo "Cannot work out Vivaldi version number" >&2
exit 1
fi
# Check if this package has already been extracted
if [ -d "Vivaldi-$VNUM" ]; then
echo "Vivaldi $VNUM has already been extracted" >&2
exit 0
fi
# Create named and numbered directory to house Vivaldi
mkdir "Vivaldi-$VNUM"
# Mount the Vivaldi .dmg
echo "Mounting ${VNUM}"
hdiutil attach "$1" -mountpoint "Vivaldi-$VNUM/.mount" -nobrowse
# If mounting failed or the user did not agree to the license, exit
if ! [ "$?" = "0" ]; then
rmdir "Vivaldi-$VNUM"
exit 1
fi
# Copy Vivaldi out of the mounted .dmg
echo "Copying Vivaldi"
cp -R "Vivaldi-$VNUM/.mount/Vivaldi.app" "Vivaldi-$VNUM"
# Unmount the Vivaldi .dmg
hdiutil detach "Vivaldi-$VNUM/.mount" > /dev/null
# Create the standalone launcher application
cd "Vivaldi-$VNUM"
mkdir -p Standalone\ Mode.app/Contents/MacOS
printf '#!/bin/sh\nopen -a "${0%%/*.app/*}"/[!\(Standalone\)]*.app --args --user-data-dir="${0%%/*.app/*}/profile"\n' > Standalone\ Mode.app/Contents/MacOS/Standalone\ Mode
chmod +x Standalone\ Mode.app/Contents/MacOS/Standalone\ Mode
# Confirm the created directory
echo "Created the directory: Vivaldi-$VNUM"
# Open the newly created directory
open .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment