Skip to content

Instantly share code, notes, and snippets.

@ruario
Last active March 7, 2024 17:54
Show Gist options
  • Save ruario/0e4f90caa59a390c4a56 to your computer and use it in GitHub Desktop.
Save ruario/0e4f90caa59a390c4a56 to your computer and use it in GitHub Desktop.
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/*}"/Vivaldi.app --args --user-data-dir="${0%%/*.app/*}/User Data"\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

Once finished, 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".


Known Issues

Autoupdate does not work well when Vivaldi is run in this way (on "Upgrade and Restart", your main prefences/settings would get used). When you receive the upgrade notification, cancel it and go to vivaldi.com (or vivaldi.net for snapshots) and download the new version, then extract it as before. Your settings from the previous build are in the "profile" folder. Copy or move this to be along side your newly extracted Vivaldi as is needed.

#!/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}"
echo y | 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/*}"/Vivaldi.app --args --user-data-dir="${0%%/*.app/*}/User Agent"\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