#!/bin/sh -eu

WAIT_LINKING_MSG='Waiting to be linked to an account...'

dropbox start -i >/dev/null
sleep 2
# Is this first start?
if dropbox status | grep -qs "^$WAIT_LINKING_MSG"; then
	link="$(dropbox start -i | sed -n '/^https:/p' | head -1)"
	[ -z "$link" ] || xdg-open "$link" >/dev/null 2>&1
fi
