|
Alain Reguera Delgado |
2c7b25 |
#!/bin/bash
|
|
Alain Reguera Delgado |
2c7b25 |
######################################################################
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
25be94 |
# tcar - The CentOS Artwork Repository automation tool.
|
|
Alain Reguera Delgado |
25be94 |
# Copyright © 2014 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
25be94 |
# This program is free software; you can redistribute it and/or
|
|
Alain Reguera Delgado |
25be94 |
# modify it under the terms of the GNU General Public License as
|
|
Alain Reguera Delgado |
25be94 |
# published by the Free Software Foundation; either version 2 of the
|
|
Alain Reguera Delgado |
25be94 |
# License, or (at your option) any later version.
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
25be94 |
# This program is distributed in the hope that it will be useful,
|
|
Alain Reguera Delgado |
25be94 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
25be94 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
25be94 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
25be94 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
25be94 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
25be94 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
25be94 |
# Alain Reguera Delgado <al@centos.org.cu>
|
|
Alain Reguera Delgado |
25be94 |
# 39 Street No. 4426 Cienfuegos, Cuba.
|
|
Alain Reguera Delgado |
2c7b25 |
#
|
|
Alain Reguera Delgado |
2c7b25 |
######################################################################
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
25be94 |
# Take one palette produced by Gimp (e.g., syslinux.gpl) as input and
|
|
Alain Reguera Delgado |
25be94 |
# outputs a list of colors in #rrggbb format set in the fourth column
|
|
Alain Reguera Delgado |
25be94 |
# of it.
|
|
Alain Reguera Delgado |
2c7b25 |
function palette_getColors {
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
local COLOR=''
|
|
Alain Reguera Delgado |
2c7b25 |
local PALETTE_COLORS=''
|
|
Alain Reguera Delgado |
2c7b25 |
local PALETTE=${1}
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
if [[ -f ${PALETTE} ]];then
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
# Retrieve the fourth column from GPL palette. The fourth
|
|
Alain Reguera Delgado |
2c7b25 |
# column of a GPL palette contains the palette commentary
|
|
Alain Reguera Delgado |
2c7b25 |
# field. The palette commentary field can be anything, but for
|
|
Alain Reguera Delgado |
2c7b25 |
# the sake of our own convenience we use it to store the color
|
|
Alain Reguera Delgado |
2c7b25 |
# value in hexadecimal format (e.g., rrggbb). Notice that you
|
|
Alain Reguera Delgado |
2c7b25 |
# can put your comments from the fifth column on, using an
|
|
Alain Reguera Delgado |
2c7b25 |
# space as field separator.
|
|
Alain Reguera Delgado |
2c7b25 |
PALETTE_COLORS=$(sed -r '1,/^#/d' ${PALETTE} \
|
|
Alain Reguera Delgado |
2c7b25 |
| gawk '{ printf "%s\n", $4 }')
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
else
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
# Redefine default background color using The CentOS Project
|
|
Alain Reguera Delgado |
2c7b25 |
# default color then.
|
|
Alain Reguera Delgado |
2c7b25 |
PALETTE_COLORS='#204c8d'
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
fi
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
# Be sure all color information be output in the #rrggbb format.
|
|
Alain Reguera Delgado |
2c7b25 |
for COLOR in ${PALETTE_COLORS};do
|
|
Alain Reguera Delgado |
2c7b25 |
if [[ ! ${COLOR} =~ '^#' ]];then
|
|
Alain Reguera Delgado |
2c7b25 |
COLOR="#${COLOR}"
|
|
Alain Reguera Delgado |
2c7b25 |
fi
|
|
Alain Reguera Delgado |
2c7b25 |
echo "${COLOR}"
|
|
Alain Reguera Delgado |
2c7b25 |
done
|
|
Alain Reguera Delgado |
2c7b25 |
|
|
Alain Reguera Delgado |
2c7b25 |
}
|