162 lines
2.9 KiB
Bash
Executable File
162 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# LOC ~/scripts/xtermmaker.sh
|
|
# CVS $Id: xtermmaker.sh,v 1.2 2001/08/08 12:01:22 heinzel Exp $
|
|
version='xtermmaker.sh Version 3.2 $Revision: 1.2 $ ($Date: 2001/08/08 12:01:22 $ $Author: heinzel $)'
|
|
|
|
### config ###
|
|
xterm=xterm
|
|
xterm_opts="-sb -sl 1024"
|
|
|
|
number=1
|
|
max_number=9
|
|
|
|
rsh=ssh
|
|
host=""
|
|
user=""
|
|
|
|
color=RAND
|
|
theme=light
|
|
themes="traditional, light"
|
|
|
|
# NOTE: Themes MUST have $max_number colors defined
|
|
theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod"
|
|
|
|
theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange"
|
|
|
|
### functions ###
|
|
show_version()
|
|
{
|
|
echo $version
|
|
}
|
|
|
|
show_help()
|
|
{
|
|
echo "Usage: xtermmaker.sh [-n <int>] [-u <user>] [-r <host>]"
|
|
echo " [-c <color>] [-g] [-b] [-z] [--t <theme>]"
|
|
echo " [-h|--help] [-V|--version]"
|
|
echo ""
|
|
echo "-n opens <int> xterms (default: $number) (max: $max_number)"
|
|
echo ""
|
|
echo "-r exec remote shell to the specified hostname"
|
|
echo "-u specified the username for the remote host"
|
|
echo ""
|
|
echo "-c set the backgroundcolor of the xterms"
|
|
echo "-g same as -c Gray"
|
|
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 " possible themes: $themes (default: $theme)"
|
|
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 ###
|
|
|
|
# read arguments from stdin
|
|
while test $# -gt 0 ; do
|
|
case "$1" in
|
|
-h|-help|--help)
|
|
show_help
|
|
exit 0
|
|
;;
|
|
-V|-version|--version)
|
|
show_version
|
|
exit 0
|
|
;;
|
|
-n|-number|--number)
|
|
number="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
-c|-color|--color)
|
|
color="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
-g)
|
|
color=Gray
|
|
shift
|
|
;;
|
|
-b)
|
|
color=BUNT
|
|
shift
|
|
;;
|
|
-z)
|
|
color=RAND
|
|
shift
|
|
;;
|
|
-t|-theme|--theme)
|
|
theme="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
-u|-user|--user)
|
|
user="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
-r|-host|--host)
|
|
host="$2"
|
|
shift
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
### action ###
|
|
|
|
test "$number" || number=1
|
|
test "$number" -le "$max_number" || number=$max_number
|
|
|
|
count=1
|
|
until test $count -gt $number ; do
|
|
|
|
title_opt="-title $count"
|
|
|
|
case "$color" in
|
|
BUNT)
|
|
eval colors=\$theme_$theme
|
|
bg_opt="-bg `echo $colors | cut -f $count -d ,`"
|
|
;;
|
|
RAND)
|
|
eval colors=\$theme_$theme
|
|
buf=`rand $max_number`
|
|
bg_opt="-bg `echo $colors | cut -f $buf -d ,`"
|
|
;;
|
|
*)
|
|
bg_opt="-bg $color"
|
|
;;
|
|
esac
|
|
|
|
fg_opt="-fg black"
|
|
|
|
pos_opt=""
|
|
|
|
if test "$host" ; then
|
|
t=$host
|
|
test "$user" && t="${user}@${host}"
|
|
exec_opt="-e $rsh $t"
|
|
fi
|
|
|
|
$xterm $xterm_opts $title_opt $bg_opt $fg_opt $pos_opt $exec_opt &
|
|
|
|
count=`expr $count + 1`
|
|
done
|
|
|
|
exit 0
|