added support for positioning xterms in columns

This commit is contained in:
heinzel
2003-02-19 12:54:18 +00:00
parent 0587bc8d10
commit 742553d99f

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# LOC ~/scripts/xtermmaker.sh # LOC ~/scripts/xtermmaker.sh
# CVS $Id: xtermmaker.sh,v 1.2 2001/08/08 12:01:22 heinzel Exp $ # CVS $Id: xtermmaker.sh,v 1.3 2003/02/19 12:54:18 heinzel Exp $
version='xtermmaker.sh Version 3.2 $Revision: 1.2 $ ($Date: 2001/08/08 12:01:22 $ $Author: heinzel $)' version='xtermmaker.sh Version 3.3 $Revision: 1.3 $ ($Date: 2003/02/19 12:54:18 $ $Author: heinzel $)'
### config ### ### config ###
xterm=xterm xterm=xterm
@@ -23,30 +23,43 @@ theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,Med
theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange" theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange"
# if cols > 0, we arange the possitions of the xterms in $cols columns
cols=0
hoffset=64
voffset=64
width=499
height=348
space=4
### functions ### ### functions ###
show_version() print_version()
{ {
echo $version echo "$version"
} }
show_help() print_help()
{ {
echo "Usage: xtermmaker.sh [-n <int>] [-u <user>] [-r <host>]" cat <<E-O-H
echo " [-c <color>] [-g] [-b] [-z] [--t <theme>]"
echo " [-h|--help] [-V|--version]" Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
echo "" [-c <color>] [-g] [-b] [-z] [--t <theme>]
echo "-n opens <int> xterms (default: $number) (max: $max_number)" [-h,--help] [-V,--version]
echo ""
echo "-r exec remote shell to the specified hostname" -n Opens <number> xterms (default: $number) (max: $max_number).
echo "-u specified the username for the remote host" -C If specified, the xterms will be aranged in <columns> columns.
echo ""
echo "-c set the backgroundcolor of the xterms" -r Exec remote shell to the specified hostname.
echo "-g same as -c Gray" -u Specifies the username for the remote host.
echo "-b generates \"Bunte XTerms\" in serial sequence"
echo "-z generates \"Bunte XTerms\" in random sequence (default)" -c Set the backgroundcolor of the xterms.
echo "-t use color theme <theme> for \"Bunte XTerms\"" -g Same as -c Gray.
echo " possible themes: $themes (default: $theme)" -b Generates 'Bunte XTerms' in serial sequence.
echo "" -z Generates 'Bunte XTerms' in random sequence (default).
-t Use color theme <theme> for 'Bunte XTerms'.
Possible themes: $themes (default: $theme)
E-O-H
} }
rand() rand()
@@ -71,11 +84,11 @@ rand()
while test $# -gt 0 ; do while test $# -gt 0 ; do
case "$1" in case "$1" in
-h|-help|--help) -h|-help|--help)
show_help print_help
exit 0 exit 0
;; ;;
-V|-version|--version) -V|-version|--version)
show_version print_version
exit 0 exit 0
;; ;;
-n|-number|--number) -n|-number|--number)
@@ -83,6 +96,11 @@ while test $# -gt 0 ; do
shift shift
shift shift
;; ;;
-C|-cols|--cols)
cols="$2"
shift
shift
;;
-c|-color|--color) -c|-color|--color)
color="$2" color="$2"
shift shift
@@ -123,6 +141,11 @@ done
test "$number" || number=1 test "$number" || number=1
test "$number" -le "$max_number" || number=$max_number test "$number" -le "$max_number" || number=$max_number
# position of the first window
column=1
hpos="$hoffset"
vpos="$voffset"
count=1 count=1
until test $count -gt $number ; do until test $count -gt $number ; do
@@ -145,7 +168,25 @@ until test $count -gt $number ; do
fg_opt="-fg black" fg_opt="-fg black"
if test "$cols" -gt 0 ; then
# position for this window
pos_opt="-geometry +${hpos}+${vpos}"
# calculate the position for the next window
if test "$column" -lt "$cols" ; then
# current column is less than max columns ->
# we can place the next window right of this one
column="`expr $column + 1`"
hpos="`expr $hpos + $width + $space`"
else
# we need a new row
column=1
hpos="$hoffset"
vpos="`expr $vpos + $height + $space`"
fi
else
pos_opt="" pos_opt=""
fi
if test "$host" ; then if test "$host" ; then
t=$host t=$host