#!/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.

DISTROS="ubuntu"

for i in $DISTROS; do
	rm -f profiles/$i*
	if [ "$1" = "--clean" ]; then
		echo "Removing profiles for: $i"
		continue
	fi
	echo "Generating profiles for: $i"
	cat profiles/profile.skel > profiles/$i-light
	cp profiles/$i-light profiles/$i-dark
	sed -i "s/ Wk/ Kw/g" profiles/$i-dark
	sed -i "s/kW/wK/g" profiles/$i-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/$i-light profiles/$i-$desc
		sed -i "s/ Wk/ $x$y/g" profiles/$i-$desc
		sed -i "s/kW/$y$x/g" profiles/$i-$desc
	done
done
