xtermmaker Ver 3.2 can select random colors from theme

This commit is contained in:
heinzel
2001-08-08 12:01:22 +00:00
parent 01db6fccd4
commit 0587bc8d10

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# LOC ~/scripts/xtermmaker.sh # LOC ~/scripts/xtermmaker.sh
# CVS $Id: xtermmaker.sh,v 1.1 2001/07/13 14:35:28 heinzel Exp $ # CVS $Id: xtermmaker.sh,v 1.2 2001/08/08 12:01:22 heinzel Exp $
version='xtermmaker.sh Version 3.1 $Revision: 1.1 $ ($Date: 2001/07/13 14:35:28 $ $Author: heinzel $)' version='xtermmaker.sh Version 3.2 $Revision: 1.2 $ ($Date: 2001/08/08 12:01:22 $ $Author: heinzel $)'
### config ### ### config ###
xterm=xterm xterm=xterm
@@ -14,14 +14,14 @@ rsh=ssh
host="" host=""
user="" user=""
color=BUNT color=RAND
theme=light theme=light
themes="traditional, light" themes="traditional, light"
# Note: Themes must have $max_number colors defined # NOTE: Themes MUST have $max_number colors defined
theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod" theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod"
theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,MediumSeaGreen,Goldenrod,SlateGrey,IndianRed" theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange"
### functions ### ### functions ###
show_version() show_version()
@@ -32,7 +32,7 @@ show_version()
show_help() show_help()
{ {
echo "Usage: xtermmaker.sh [-n <int>] [-u <user>] [-r <host>]" echo "Usage: xtermmaker.sh [-n <int>] [-u <user>] [-r <host>]"
echo " [-c <color>] [-g] [-b] [--t <theme>]" echo " [-c <color>] [-g] [-b] [-z] [--t <theme>]"
echo " [-h|--help] [-V|--version]" echo " [-h|--help] [-V|--version]"
echo "" echo ""
echo "-n opens <int> xterms (default: $number) (max: $max_number)" echo "-n opens <int> xterms (default: $number) (max: $max_number)"
@@ -42,12 +42,28 @@ show_help()
echo "" echo ""
echo "-c set the backgroundcolor of the xterms" echo "-c set the backgroundcolor of the xterms"
echo "-g same as -c Gray" echo "-g same as -c Gray"
echo "-b generates \"Bunte XTerms\" (default)" echo "-b generates \"Bunte XTerms\" in serial sequence"
echo "-z generates \"Bunte XTerms\" in random sequence (default)"
echo "-t use color theme <theme> for \"Bunte XTerms\"" echo "-t use color theme <theme> for \"Bunte XTerms\""
echo " possible themes: $themes (default: $theme)" echo " possible themes: $themes (default: $theme)"
echo "" echo ""
} }
rand()
{
# Usage: rand <int>
local i="${1:-1}"
local f=/proc/uptime
local b=""
local p=0
b=`md5sum $f | tr -d "[:alpha:] [:punct:]"`
p=`expr ${#b} - 1`
b=`echo $b | cut -c ${p}-`
expr \( $b \* $i \) / 100 + 1
}
### argv ### ### argv ###
@@ -80,6 +96,10 @@ while test $# -gt 0 ; do
color=BUNT color=BUNT
shift shift
;; ;;
-z)
color=RAND
shift
;;
-t|-theme|--theme) -t|-theme|--theme)
theme="$2" theme="$2"
shift shift
@@ -101,18 +121,27 @@ done
### action ### ### action ###
test "$number" || number=1 test "$number" || number=1
test "$number" -le "$max_number" || number=$max_number
count=1 count=1
until test $count -gt $number ; do until test $count -gt $number ; do
title_opt="-title $count" title_opt="-title $count"
if test "$color" = "BUNT" ; then case "$color" in
BUNT)
eval colors=\$theme_$theme eval colors=\$theme_$theme
bg_opt="-bg `echo $colors | cut -f $count -d ,`" bg_opt="-bg `echo $colors | cut -f $count -d ,`"
else ;;
RAND)
eval colors=\$theme_$theme
buf=`rand $max_number`
bg_opt="-bg `echo $colors | cut -f $buf -d ,`"
;;
*)
bg_opt="-bg $color" bg_opt="-bg $color"
fi ;;
esac
fg_opt="-fg black" fg_opt="-fg black"