added support for positioning xterms in columns
This commit is contained in:
@@ -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 <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 ""
|
||||
cat <<E-O-H
|
||||
|
||||
Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
|
||||
[-c <color>] [-g] [-b] [-z] [--t <theme>]
|
||||
[-h,--help] [-V,--version]
|
||||
|
||||
-n Opens <number> xterms (default: $number) (max: $max_number).
|
||||
-C If specified, the xterms will be aranged in <columns> 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 <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
|
||||
|
||||
Reference in New Issue
Block a user