#!/bin/sh # # creating colorflavours of fluxboxstyles # # Copyright (c) 2003,2004 Mathias Gumz # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # input is read always from stdin and stdout # # TAG -> @TAG\+@: # COLOR -> #rrggbb or grey60, whatever, the real color # # e - extract map # # t - color -> tag # c - tag -> color # # h - help # v - version # display_help() { cat << EOF ABOUT fbcolor - create colorflavours of fluxboxstyles SYNOPSIS $ cat ifile | fbcolor [-ecthHv] > ofile OPTIONS -h display this help -H display detailed usageinformation -v prints the version -t file using a mapfile to turn tags into colors -c file using a mapfile to turn colors into tags -e extract colors from a stylefile an create a mapfile EOF } display_addhelp() { cat << EOF DESCRIPTION fbcolor is a small and handy (hopefully) tool to create different colored flavours of a fluxbox-style. basic idea is not to use real colors in the stylefile (#rrggbb or grey60 or whatever) but TAGS. then one creates a MAPFILE which references the TAGS to realcolors and use this MAPFILE in combination with the TAGGED stylefile to create the real stylefile. 1.step: create the MAPFILE its not a _rule_ to create the MAPFILE first and the tagged stylefile later. you can built them simultaneously or even create the MAPFILE from already built styles (see 2.step). a mapfile looks like: @FONTS@ #000000 @MASTER@ #222244 @COLOR1@ #444455 @COLOR2@ blue4 ATTENTION: the @ is essential !!! 2.step: create the TAGGED stylefile just use @YOURTAG@ ...whatever to mark different colors, eg menu.title.color: @TITLECOLOR@ window.title.focus.colorTo: @COLORTO@ ATTENTION: the @ is essential !!! to create a tagged stylefile from an normal stylefile one has to do the following: 1. cat style | fbcolor -e > style.map 2. cat style.map | fbcolor -t style > style.tagged thats it. one can then copy and modify this mapfile as normal 3.step: create the final style now one uses the generated mapfiles and creates all the nice flavours of a style one wants to. thats easy: shell$> cat style.map | fbcolor -c style.tagged > newstyle and thats it too :) BUGS not yet known AUTHOR mathias gumz EOF } display_version() { cat << EOF fbcolor v0.1 - (c) by m.gumz 2003-25-07 EOF } getopts "et:c:hHv" OPTION case "${OPTION}" in h ) display_help exit 0 ;; H ) display_help display_addhelp exit 0 ;; v ) display_version exit 0 ;; #extract colors #create map-file e ) sed -n '/[cC]olor/p' | \ sed -e 's/^.*:[ \t]*\(.*\)[ \t]*$/\1/g' | \ sort | \ uniq | \ sed = | sed 'N;s/\n/ \t/' | sed 's/^ *//g;s/^/@COLOR/g;s/\(@COLOR[0-9]\+\)/\1@/g' ;; c ) cp $OPTARG tmp.$$ while read LINE do COLOR=`echo $LINE | sed -n 's/^@[[:alnum:]]\+@ *//p'` TAG=`echo $LINE | sed -n 's/^\(@[[:alnum:]]\+@\).*$/\1/p'` cat tmp.$$ | sed "s/${TAG}/${COLOR}/g" > tmp_.$$ #&& \ mv tmp_.$$ tmp.$$ done && cat tmp.$$ && rm tmp.$$ ;; t ) cp $OPTARG tmp.$$ while read LINE do COLOR=`echo $LINE | sed -n 's/^@[[:alnum:]]\+@ *//p'` TAG=`echo $LINE | sed -n 's/^\(@[[:alnum:]]\+@\).*$/\1/p'` cat tmp.$$ | sed "s/${COLOR}/${TAG}/g" > tmp_.$$ #&& \ mv tmp_.$$ tmp.$$ done && cat tmp.$$ && rm tmp.$$ ;; esac