New cool features.
- can use wterms instead of xterms (-w) - config file within users homedir (.xtermmakerrc) - color themes can be defined within the config file - presets of options can be defined within the config file
This commit is contained in:
26
DOT.xtermmakerrc
Normal file
26
DOT.xtermmakerrc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# ~/.xtermmakerrc
|
||||||
|
|
||||||
|
[themes]
|
||||||
|
traditional:
|
||||||
|
SteelBlue,SeaGreen,orange,gold,tomato
|
||||||
|
CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod
|
||||||
|
|
||||||
|
light:
|
||||||
|
SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue
|
||||||
|
DarkSeaGreen,khaki,CornflowerBlue,orange
|
||||||
|
|
||||||
|
blay:
|
||||||
|
lavender,DimGray,SlateGray,LightSlateGray,LightSteelBlue
|
||||||
|
SkyBlue,CornflowerBlue,SteelBlue
|
||||||
|
|
||||||
|
o2:
|
||||||
|
peru,SeaGreen,SteelBlue,CornflowerBlue,LightSteelBlue
|
||||||
|
LightSlateGray,lavender
|
||||||
|
|
||||||
|
[presets]
|
||||||
|
devel:
|
||||||
|
-geometry +2-64
|
||||||
|
-geometry +600+64
|
||||||
|
-bg black -fg gray -fn 10x20 -geometry +2+2
|
||||||
|
-bg black -fg gray -fn 10x20 -geometry +456-2
|
||||||
|
|
||||||
220
xtermmaker.sh
220
xtermmaker.sh
@@ -1,28 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# LOC ~/scripts/xtermmaker.sh
|
# ~/scripts/xtermmaker.sh
|
||||||
# CVS $Id: xtermmaker.sh,v 1.7 2003/10/13 14:21:02 heinzel Exp $
|
# $Id: xtermmaker.sh,v 1.8 2005/07/19 12:12:37 heinzel Exp $
|
||||||
version='XTermMaker Version 3.4 $Revision: 1.7 $ ($Date: 2003/10/13 14:21:02 $ $Author: heinzel $)'
|
VERSION='XTermMaker Version 4.0 $Revision: 1.8 $ ($Date: 2005/07/19 12:12:37 $ $Author: heinzel $)'
|
||||||
|
|
||||||
### config ###
|
### config ###
|
||||||
xterm=xterm
|
CONFIG="${HOME}/.xtermmakerrc"
|
||||||
xterm_opts="-sb -sl 1024"
|
|
||||||
|
|
||||||
many=1
|
NUMBER=1
|
||||||
|
|
||||||
rsh=ssh
|
COLOR="RAND"
|
||||||
host=""
|
DEFAULT_THEME="light"
|
||||||
user=""
|
|
||||||
|
|
||||||
color=RAND
|
XTERM="xterm"
|
||||||
theme=light
|
#XTERM="echo xterm"
|
||||||
|
XTERM_OPTS="-sb -sl 1024"
|
||||||
|
|
||||||
theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod"
|
RSH="ssh"
|
||||||
theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange"
|
HOST=""
|
||||||
theme_blay="lavender,DimGray,SlateGray,LightSlateGray,LightSteelBlue,SkyBlue,CornflowerBlue,SteelBlue"
|
USER=""
|
||||||
themes="`set | grep "^theme_" | cut -f1 -d= | cut -c7- | tr '\n' ' '`"
|
|
||||||
|
|
||||||
# if cols > 0, we arange the possitions of the xterms in $cols columns
|
# if cols > 0, we arange the possitions of the xterms in $cols columns
|
||||||
cols=0
|
COLS=0
|
||||||
hoffset=64
|
hoffset=64
|
||||||
voffset=64
|
voffset=64
|
||||||
width=499
|
width=499
|
||||||
@@ -31,20 +29,18 @@ space=4
|
|||||||
|
|
||||||
|
|
||||||
### functions ###
|
### functions ###
|
||||||
print_version()
|
print_version() {
|
||||||
{
|
echo "$VERSION"
|
||||||
echo "$version"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_help()
|
print_help() {
|
||||||
{
|
cat <<EOH
|
||||||
cat <<EOH
|
|
||||||
|
|
||||||
Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
|
Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
|
||||||
[-c <color>] [-g] [-b] [-z] [-t <theme>]
|
[-c <color>] [-g] [-b] [-z] [-t <theme>] [-p <preset>]
|
||||||
[-h,--help] [-V,--version]
|
[-w] [-h,--help] [-V,--version] [- <xterm options>]
|
||||||
|
|
||||||
-n Opens <number> xterms (default: $number).
|
-n Opens <number> xterms (default: $NUMBER).
|
||||||
-C If specified, the xterms will be aranged in <columns> columns.
|
-C If specified, the xterms will be aranged in <columns> columns.
|
||||||
|
|
||||||
-r Exec remote shell to the specified hostname.
|
-r Exec remote shell to the specified hostname.
|
||||||
@@ -55,13 +51,20 @@ Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
|
|||||||
-b Generates 'Bunte XTerms' in serial sequence.
|
-b Generates 'Bunte XTerms' in serial sequence.
|
||||||
-z Generates 'Bunte XTerms' in random sequence (default).
|
-z Generates 'Bunte XTerms' in random sequence (default).
|
||||||
-t Use color theme <theme> for 'Bunte XTerms'.
|
-t Use color theme <theme> for 'Bunte XTerms'.
|
||||||
Possible themes: $themes (default: $theme)
|
Defined themes: $THEMES (default: $DEFAULT_THEME)
|
||||||
|
|
||||||
|
-w Use 'wterm' with transparency instead of xterm.
|
||||||
|
|
||||||
|
-p Use preset <preset>.
|
||||||
|
Defined presets: $PRESETS
|
||||||
|
|
||||||
|
Anything after a standalone dash (-) will be passed as options
|
||||||
|
to the xterm application.
|
||||||
|
|
||||||
EOH
|
EOH
|
||||||
}
|
}
|
||||||
|
|
||||||
rand()
|
rand() {
|
||||||
{
|
|
||||||
# Usage: rand <int>
|
# Usage: rand <int>
|
||||||
local m="${1:-1}"
|
local m="${1:-1}"
|
||||||
local f="/dev/urandom"
|
local f="/dev/urandom"
|
||||||
@@ -72,9 +75,72 @@ rand()
|
|||||||
|
|
||||||
expr \( $n \* $m \) / 100 + 1
|
expr \( $n \* $m \) / 100 + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### argv ###
|
parse_config() {
|
||||||
|
# Usage: parse_config
|
||||||
|
local f="${CONFIG}"
|
||||||
|
local section="";
|
||||||
|
local theme="";
|
||||||
|
local preset="";
|
||||||
|
local buf="";
|
||||||
|
|
||||||
|
THEMES=""
|
||||||
|
PRESETS=""
|
||||||
|
|
||||||
|
if test "X${f}" != "X" -a -r "$f" ; then
|
||||||
|
while read line ; do
|
||||||
|
if expr "$line" : "#.*" >/dev/null ; then
|
||||||
|
continue
|
||||||
|
elif test "X${line}" = "X" ; then
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif expr "$line" : "\[.*\]" >/dev/null ; then
|
||||||
|
section="$line"
|
||||||
|
|
||||||
|
elif test "X${section}" = "X[themes]" ; then
|
||||||
|
if expr "$line" : ".*:" >/dev/null ; then
|
||||||
|
theme="`echo \"$line\" | tr -d ': '`"
|
||||||
|
THEMES="${THEMES}${theme}, "
|
||||||
|
elif test "X${theme}" != "X" ; then
|
||||||
|
eval THEME_${theme}="\"\${THEME_${theme}}${line%,},\""
|
||||||
|
else
|
||||||
|
echo "Error parsing themes config ($f)" >&2
|
||||||
|
fi
|
||||||
|
elif test "X${section}" = "X[presets]" ; then
|
||||||
|
if expr "$line" : ".*:" >/dev/null ; then
|
||||||
|
preset="`echo \"$line\" | tr -d ': '`"
|
||||||
|
PRESETS="${PRESETS}${preset}, "
|
||||||
|
elif test "X${preset}" != "X" ; then
|
||||||
|
buf="$line
|
||||||
|
"
|
||||||
|
eval PRESET_${preset}="\"\${PRESET_${preset}}${buf}\""
|
||||||
|
else
|
||||||
|
echo "Error parsing presets config ($f)" >&2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error parsing config ($f): Unknown section '$section'" >&2
|
||||||
|
fi
|
||||||
|
done < "$f"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Do cosmetic on the themes and presets list.
|
||||||
|
THEMES="${THEMES%, }"
|
||||||
|
PRESETS="${PRESETS%, }"
|
||||||
|
|
||||||
|
# If the default theme was not defined (or has zero colors), define it.
|
||||||
|
eval buf="\"\${THEME_${DEFAULT_THEME}}\""
|
||||||
|
if test "X${buf}" = "X" ; then
|
||||||
|
eval THEME_${DEFAULT_THEME}="\"gray\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the default preset was not defined, define it with zero entries.
|
||||||
|
if test "X${PRESET_default}" = "X" ; then
|
||||||
|
PRESET_default=""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
### set options ###
|
||||||
|
parse_config
|
||||||
|
|
||||||
# read arguments from stdin
|
# read arguments from stdin
|
||||||
while test $# -gt 0 ; do
|
while test $# -gt 0 ; do
|
||||||
@@ -88,73 +154,116 @@ while test $# -gt 0 ; do
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-n|-number|--number)
|
-n|-number|--number)
|
||||||
many="$2"
|
NUMBER="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-C|-cols|--cols)
|
-C|-cols|--cols)
|
||||||
cols="$2"
|
COLS="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-c|-color|--color)
|
-c|-color|--color)
|
||||||
color="$2"
|
COLOR="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-g)
|
-g)
|
||||||
color=Gray
|
COLOR=Gray
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-b)
|
-b)
|
||||||
color=BUNT
|
COLOR=BUNT
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-z)
|
-z)
|
||||||
color=RAND
|
COLOR=RAND
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-t|-theme|--theme)
|
-t|-theme|--theme)
|
||||||
theme="$2"
|
THEME="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-p|-preset|--preset)
|
||||||
|
PRESET="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-u|-user|--user)
|
-u|-user|--user)
|
||||||
user="$2"
|
USER="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-r|-host|--host)
|
-r|-host|--host)
|
||||||
host="$2"
|
HOST="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-w)
|
||||||
|
if test -x "`which wterm`" ; then
|
||||||
|
XTERM="wterm"
|
||||||
|
XTERM_OPTS="$XTERM_OPTS -tr -sh"
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-|--)
|
||||||
|
shift
|
||||||
|
XTRA_OPTS=$@
|
||||||
|
break
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
### action ###
|
test "X${THEME}" = "X" && THEME="$DEFAULT_THEME"
|
||||||
|
test "X${PRESET}" = "X" && PRESET="default"
|
||||||
|
test "X${NUMBER}" = "X" && NUMBER=1
|
||||||
|
|
||||||
test "$many" || number=1
|
eval buf="\"\${THEME_${THEME}}\""
|
||||||
|
if test "X${buf}" = "X" ; then
|
||||||
|
echo "Theme '$THEME' is not defined." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! set | grep "^PRESET_${PRESET}=" >/dev/null ; then
|
||||||
|
echo "Preset '$PRESET' is not defined." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
### action ###
|
||||||
|
|
||||||
# position of the first window
|
# position of the first window
|
||||||
column=1
|
column=1
|
||||||
hpos="$hoffset"
|
hpos="$hoffset"
|
||||||
vpos="$voffset"
|
vpos="$voffset"
|
||||||
|
|
||||||
eval colors=\$theme_$theme
|
eval colors="\"\${THEME_${THEME}%,}\""
|
||||||
ncolors="`echo \"$colors\" | tr -d [[:alnum:]]`"
|
ncolors="`echo \"$colors\" | tr -d [[:alnum:]]`"
|
||||||
ncolors="${#ncolors}"
|
ncolors="${#ncolors}"
|
||||||
ncolors="`expr $ncolors + 1`"
|
ncolors="`expr $ncolors + 1`"
|
||||||
|
|
||||||
|
eval presets="\"\${PRESET_${PRESET}}\""
|
||||||
|
npresets="`echo \"$presets\" | wc -l`"
|
||||||
|
npresets="`expr $npresets - 1`"
|
||||||
|
|
||||||
xterm_count=1
|
xterm_count=1
|
||||||
color_count=1
|
color_count=1
|
||||||
until test $xterm_count -gt $many ; do
|
until test $xterm_count -gt $NUMBER ; do
|
||||||
|
|
||||||
|
if test "1${xterm_count}" -le "1${npresets}" ; then
|
||||||
|
set_opts="`echo \"$presets\" | sed -ne \"${xterm_count}p\"`"
|
||||||
|
else
|
||||||
|
set_opts=""
|
||||||
|
fi
|
||||||
|
|
||||||
title_opt="-title $xterm_count"
|
title_opt="-title $xterm_count"
|
||||||
|
|
||||||
case "$color" in
|
case "$COLOR" in
|
||||||
|
NONE)
|
||||||
|
;;
|
||||||
BUNT)
|
BUNT)
|
||||||
bg_opt="-bg `echo $colors | cut -f $color_count -d ,`"
|
bg_opt="-bg `echo $colors | cut -f $color_count -d ,`"
|
||||||
|
fg_opt="-fg ${FG_COLOR-black}"
|
||||||
if test "$color_count" -lt "$ncolors" ; then
|
if test "$color_count" -lt "$ncolors" ; then
|
||||||
color_count=`expr $color_count + 1`
|
color_count=`expr $color_count + 1`
|
||||||
else
|
else
|
||||||
@@ -164,20 +273,20 @@ until test $xterm_count -gt $many ; do
|
|||||||
RAND)
|
RAND)
|
||||||
color_count=`rand $ncolors`
|
color_count=`rand $ncolors`
|
||||||
bg_opt="-bg `echo $colors | cut -f $color_count -d ,`"
|
bg_opt="-bg `echo $colors | cut -f $color_count -d ,`"
|
||||||
|
fg_opt="-fg ${FG_COLOR-black}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
bg_opt="-bg $color"
|
bg_opt="-bg $COLOR"
|
||||||
|
fg_opt="-fg ${FG_COLOR-black}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
fg_opt="-fg black"
|
if test "$COLS" -gt 0 ; then
|
||||||
|
|
||||||
if test "$cols" -gt 0 ; then
|
|
||||||
# position for this window
|
# position for this window
|
||||||
pos_opt="-geometry +${hpos}+${vpos}"
|
pos_opt="-geometry +${hpos}+${vpos}"
|
||||||
|
|
||||||
# calculate the position for the next window
|
# calculate the position for the next window
|
||||||
if test "$column" -lt "$cols" ; then
|
if test "$column" -lt "$COLS" ; then
|
||||||
# current column is less than max columns ->
|
# current column is less than max columns ->
|
||||||
# we can place the next window right of this one
|
# we can place the next window right of this one
|
||||||
column="`expr $column + 1`"
|
column="`expr $column + 1`"
|
||||||
@@ -192,13 +301,16 @@ until test $xterm_count -gt $many ; do
|
|||||||
pos_opt=""
|
pos_opt=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$host" ; then
|
if test "X${HOST}" != "X" ; then
|
||||||
t=$host
|
t="$HOST"
|
||||||
test "$user" && t="${user}@${host}"
|
if test "X${USER}" != "X" ; then
|
||||||
exec_opt="-e $rsh $t"
|
t="${USER}@${HOST}"
|
||||||
|
fi
|
||||||
|
exec_opt="-e $RSH $t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$xterm $xterm_opts $title_opt $bg_opt $fg_opt $pos_opt $exec_opt &
|
$XTERM $XTERM_OPTS $title_opt $bg_opt $fg_opt $pos_opt \
|
||||||
|
$set_opts $XTRA_OPTS $exec_opt &
|
||||||
xterm_count=`expr $xterm_count + 1`
|
xterm_count=`expr $xterm_count + 1`
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user