#!/bin/sh
#    generate: dynamically generate all profiles
#    Copyright (C) 2008 Canonical Ltd.
#
#    Authors: Dustin Kirkland <kirkland@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 of the License.
#
#    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 should be run during in the './debian/rules get-orig-source'
# step.

rm -f profiles/light profiles/dark profiles/black profiles/*_*
if [ "$1" = "--clean" ]; then
	echo "Removing generated profiles"
	exit 0
fi
echo "Generating profiles"
cat profiles_generator/profile.skel > profiles/light
cp profiles/light profiles/dark
sed -i "s/ Wk/ Kw/g" profiles/dark
sed -i "s/kW/wK/g" profiles/dark
for j in "B-light_blue" "b-dark_blue" "C-light_cyan" "c-dark_cyan" "G-light_green" "g-dark_green" "M-light_purple" "m-dark_purple" "R-light_red" "r-dark_red" "Y-light_yellow" "y-dark_yellow" "k-black"; do
	x=$(echo "$j" | awk -F"-" '{print $1}')
	desc=$(echo "$j" | awk -F"-" '{print $2}')
	y="w"
	if echo "$desc" | grep -qs "light"; then
		y="k"
	fi
	cp profiles/light profiles/$desc
	sed -i "s/ Wk/ $x$y/g" profiles/$desc
	sed -i "s/kW/$y$x/g" profiles/$desc
done
