From 742553d99f7fba36afc3ce0254867302e2894fc6 Mon Sep 17 00:00:00 2001 From: heinzel Date: Wed, 19 Feb 2003 12:54:18 +0000 Subject: [PATCH] added support for positioning xterms in columns --- xtermmaker.sh | 89 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/xtermmaker.sh b/xtermmaker.sh index 46c2b69..f0f16f7 100755 --- a/xtermmaker.sh +++ b/xtermmaker.sh @@ -1,7 +1,7 @@ #!/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 $)' +# CVS $Id: xtermmaker.sh,v 1.3 2003/02/19 12:54:18 heinzel Exp $ +version='xtermmaker.sh Version 3.3 $Revision: 1.3 $ ($Date: 2003/02/19 12:54:18 $ $Author: heinzel $)' ### config ### 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" +# 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 ### -show_version() +print_version() { - echo $version + echo "$version" } -show_help() +print_help() { - echo "Usage: xtermmaker.sh [-n ] [-u ] [-r ]" - echo " [-c ] [-g] [-b] [-z] [--t ]" - echo " [-h|--help] [-V|--version]" - echo "" - echo "-n opens 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 for \"Bunte XTerms\"" - echo " possible themes: $themes (default: $theme)" - echo "" + cat <] [-C ] [-u ] [-r ] + [-c ] [-g] [-b] [-z] [--t ] + [-h,--help] [-V,--version] + + -n Opens xterms (default: $number) (max: $max_number). + -C If specified, the xterms will be aranged in columns. + + -r Exec remote shell to the specified hostname. + -u Specifies the username for the remote host. + + -c Set the backgroundcolor of the xterms. + -g Same as -c Gray. + -b Generates 'Bunte XTerms' in serial sequence. + -z Generates 'Bunte XTerms' in random sequence (default). + -t Use color theme for 'Bunte XTerms'. + Possible themes: $themes (default: $theme) + +E-O-H } rand() @@ -71,11 +84,11 @@ rand() while test $# -gt 0 ; do case "$1" in -h|-help|--help) - show_help + print_help exit 0 ;; -V|-version|--version) - show_version + print_version exit 0 ;; -n|-number|--number) @@ -83,6 +96,11 @@ while test $# -gt 0 ; do shift shift ;; + -C|-cols|--cols) + cols="$2" + shift + shift + ;; -c|-color|--color) color="$2" shift @@ -123,6 +141,11 @@ done test "$number" || number=1 test "$number" -le "$max_number" || number=$max_number +# position of the first window +column=1 +hpos="$hoffset" +vpos="$voffset" + count=1 until test $count -gt $number ; do @@ -145,7 +168,25 @@ until test $count -gt $number ; do fg_opt="-fg black" - pos_opt="" + 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="" + fi if test "$host" ; then t=$host