#!/bin/bash
#
# Copyright (C) 2012 Canonical, Ltd.
#
# Authors:
#  Olivier Tilloy <olivier.tilloy@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This script is meant to be run at startup the first time
# Ubuntu is launched after installation.

CONFIGDIR=$HOME/.config
if [ ! -d "$CONFIGDIR" ]; then
    mkdir $CONFIGDIR
fi

TOKEN=$CONFIGDIR/.ufa-first-run
if [ -f $TOKEN ]; then
    # the token already exists, this is not the first run
    exit 1
fi
# create the token to ensure we’re run only once
touch $TOKEN


### BEGIN: custom functions that need to run the first time ###

# Chromium first run setup, ensure it uses the system title bar and border
CHROMIUMDIR=$CONFIGDIR/chromium/Default
if [ ! -d "$CHROMIUMDIR" ]; then
    mkdir -p $CHROMIUMDIR
fi
PREFSFILE=$CHROMIUMDIR/Preferences
if [ ! -f $PREFSFILE ]; then
    # do not override an existing Preferences file
    cp /usr/share/chromium-browser/master_preferences $PREFSFILE
fi

### END: custom functions that need to run the first time ###

exit 0

