|
|
b47c3d |
#!/bin/bash
|
|
|
b47c3d |
#
|
|
|
9837e3 |
# render_svg_getColors.sh -- This function takes one palette produced
|
|
|
9837e3 |
# by Gimp (e.g., syslinux.gpl) as input and outputs a list of colors
|
|
|
9837e3 |
# in the specified format. In order for this function to output the
|
|
|
9837e3 |
# color in the format specified, it is needed that the fourth column
|
|
|
9837e3 |
# in the gpl palette be set in the `rrggbb' format and the appropriate
|
|
|
9837e3 |
# conversion be implemented here.
|
|
|
9837e3 |
#
|
|
|
9837e3 |
# Notice that using both the `--head' and `--tail' options it is
|
|
|
9837e3 |
# possible to control how many consecutive items does the list of
|
|
|
9837e3 |
# colors is going to have. It is possible to output all colors in the
|
|
|
9837e3 |
# list, or a consecutive range of them.
|
|
|
b47c3d |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
b47c3d |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b47c3d |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
b47c3d |
# General Public License for more details.
|
|
|
b47c3d |
#
|
|
|
b47c3d |
# You should have received a copy of the GNU General Public License
|
|
|
b47c3d |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
b47c3d |
# ----------------------------------------------------------------------
|
|
|
b47c3d |
# $Id$
|
|
|
b47c3d |
# ----------------------------------------------------------------------
|
|
|
b47c3d |
|
|
|
a363a7 |
function render_svg_getColors {
|
|
|
b47c3d |
|
|
|
9837e3 |
# Define short options.
|
|
|
9837e3 |
local ARGSS=''
|
|
|
9837e3 |
|
|
|
9837e3 |
# Define long options.
|
|
|
9837e3 |
local ARGSL='head:,tail:,format:'
|
|
|
9837e3 |
|
|
|
9837e3 |
# Initialize ARGUMENTS with an empty value and set it as local
|
|
|
9837e3 |
# variable to this function scope.
|
|
|
9837e3 |
local ARGUMENTS=''
|
|
|
9837e3 |
|
|
|
9837e3 |
# Initialize both head and tail values to return the first line of
|
|
|
9837e3 |
# color information from the palette.
|
|
|
9837e3 |
local HEAD=1
|
|
|
9837e3 |
local TAIL=1
|
|
|
9837e3 |
|
|
|
9837e3 |
# Initialize format value used as default when no format option be
|
|
|
9837e3 |
# provided.
|
|
|
9837e3 |
local FORMAT='rrggbb'
|
|
|
9837e3 |
|
|
|
9837e3 |
# Initialize list of colors.
|
|
|
9837e3 |
local COLORS=''
|
|
|
9837e3 |
|
|
|
9837e3 |
# Redefine ARGUMENTS variable using current positional parameters.
|
|
|
9837e3 |
cli_parseArgumentsReDef "$@"
|
|
|
9837e3 |
|
|
|
9837e3 |
# Redefine ARGUMENTS variable using getopt output.
|
|
|
9837e3 |
cli_parseArguments
|
|
|
9837e3 |
|
|
|
9837e3 |
# Redefine positional parameters using ARGUMENTS variable.
|
|
|
9837e3 |
eval set -- "$ARGUMENTS"
|
|
|
9837e3 |
|
|
|
9837e3 |
# Look for options passed through positional parameters.
|
|
|
9837e3 |
while true;do
|
|
|
9837e3 |
|
|
|
9837e3 |
case "$1" in
|
|
|
9837e3 |
|
|
|
9837e3 |
--head )
|
|
|
9837e3 |
HEAD=$2
|
|
|
9837e3 |
shift 2
|
|
|
9837e3 |
;;
|
|
|
9837e3 |
|
|
|
9837e3 |
--tail )
|
|
|
9837e3 |
TAIL=$2
|
|
|
9837e3 |
shift 2
|
|
|
9837e3 |
;;
|
|
|
9837e3 |
|
|
|
9837e3 |
--format )
|
|
|
9837e3 |
FORMAT=$2
|
|
|
9837e3 |
shift 2
|
|
|
9837e3 |
;;
|
|
|
9837e3 |
|
|
|
9837e3 |
-- )
|
|
|
9837e3 |
shift 1
|
|
|
9837e3 |
break
|
|
|
9837e3 |
;;
|
|
|
9837e3 |
esac
|
|
|
9837e3 |
done
|
|
|
9837e3 |
|
|
|
9837e3 |
# Define path to gpl palette. This is the first file we use to
|
|
|
9837e3 |
# retrive color information from. Only the first file provided
|
|
|
9837e3 |
# will be used.
|
|
|
9837e3 |
local PALETTE=$(echo $@ | cut -d' ' -f1)
|
|
|
9837e3 |
|
|
|
9837e3 |
if [[ $PALETTE == '' ]];then
|
|
|
9837e3 |
|
|
|
9837e3 |
# Define palette path inside the theme's artistic motif.
|
|
|
9837e3 |
local MOTIF_PALETTE=$(cli_getRepoTLDir)/Identity/Images/Themes/$(cli_getPathComponent $ACTIONVAL --motif)/Palettes/grub.gpl
|
|
|
9837e3 |
|
|
|
9837e3 |
# Define palette path inside the theme's design model.
|
|
|
9837e3 |
local MODEL_PALETTE=$(cli_getRepoTLDir)/Identity/Models/Themes/${THEME_MODEL_NAME}/Palettes/grub.gpl
|
|
|
9837e3 |
|
|
|
9837e3 |
# Redefine default background color using palettes provided by
|
|
|
9837e3 |
# artistic motif first, and design model later. Assuming none
|
|
|
9837e3 |
# of them is present, use The CentOS Project default color
|
|
|
9837e3 |
# then.
|
|
|
9837e3 |
if [[ -f $MOTIF_PALETTE ]];then
|
|
|
9837e3 |
COLORS=$(render_svg_getColors $MOTIF_PALETTE --head=1 --tail=1)
|
|
|
9837e3 |
elif [[ -f $MODEL_PALETTE ]];then
|
|
|
9837e3 |
COLORS=$(render_svg_getColors $MODEL_PALETTE --head=1 --tail=1)
|
|
|
9837e3 |
else
|
|
|
9837e3 |
COLORS='#204c8d'
|
|
|
9837e3 |
fi
|
|
|
9837e3 |
|
|
|
9837e3 |
else
|
|
|
9837e3 |
|
|
|
9837e3 |
# Retrive the fourth column from GPL palette. The fourth
|
|
|
9837e3 |
# column of a GPL palette contains the palette commentary
|
|
|
9837e3 |
# field. The palette commentary field can be anything, but for
|
|
|
9837e3 |
# the sake of our own convenience we use it to store the color
|
|
|
9837e3 |
# value in hexadecimal format (e.g., rrggbb). Notice that you
|
|
|
9837e3 |
# can put your comments from the fifth column on using an
|
|
|
9837e3 |
# space as field separator.
|
|
|
9837e3 |
COLORS=$(sed -r '1,/^#/d' $PALETTE \
|
|
|
9837e3 |
| awk '{ printf "%s\n", $4 }' | head -n $HEAD | tail -n $TAIL)
|
|
|
9837e3 |
|
|
|
9837e3 |
fi
|
|
|
9837e3 |
|
|
|
9837e3 |
# Implement color formats convertions from rrggbb to other formats
|
|
|
9837e3 |
# that you might need to use.
|
|
|
9837e3 |
for COLOR in $COLORS;do
|
|
|
9837e3 |
|
|
|
9837e3 |
case $FORMAT in
|
|
|
9837e3 |
|
|
|
9837e3 |
rrggbb|* )
|
|
|
9837e3 |
if [[ ! $COLOR =~ '^#' ]];then
|
|
|
9837e3 |
COLOR="#${COLOR}"
|
|
|
9837e3 |
fi
|
|
|
9837e3 |
;;
|
|
|
9837e3 |
|
|
|
9837e3 |
esac
|
|
|
9837e3 |
|
|
|
9837e3 |
# Output color value.
|
|
|
9837e3 |
echo "$COLOR"
|
|
|
9837e3 |
|
|
|
9837e3 |
done
|
|
|
9837e3 |
|
|
|
b47c3d |
}
|