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
|
||||
# LOC ~/scripts/xtermmaker.sh
|
||||
# CVS $Id: xtermmaker.sh,v 1.7 2003/10/13 14:21:02 heinzel Exp $
|
||||
version='XTermMaker Version 3.4 $Revision: 1.7 $ ($Date: 2003/10/13 14:21:02 $ $Author: heinzel $)'
|
||||
# ~/scripts/xtermmaker.sh
|
||||
# $Id: xtermmaker.sh,v 1.8 2005/07/19 12:12:37 heinzel Exp $
|
||||
VERSION='XTermMaker Version 4.0 $Revision: 1.8 $ ($Date: 2005/07/19 12:12:37 $ $Author: heinzel $)'
|
||||
|
||||
### config ###
|
||||
xterm=xterm
|
||||
xterm_opts="-sb -sl 1024"
|
||||
CONFIG="${HOME}/.xtermmakerrc"
|
||||
|
||||
many=1
|
||||
NUMBER=1
|
||||
|
||||
rsh=ssh
|
||||
host=""
|
||||
user=""
|
||||
COLOR="RAND"
|
||||
DEFAULT_THEME="light"
|
||||
|
||||
color=RAND
|
||||
theme=light
|
||||
XTERM="xterm"
|
||||
#XTERM="echo xterm"
|
||||
XTERM_OPTS="-sb -sl 1024"
|
||||
|
||||
theme_traditional="SteelBlue,SeaGreen,orange,gold,tomato,CadetBlue,SlateGrey,MediumSeaGreen,Goldenrod"
|
||||
theme_light="SlateGrey,MediumSeaGreen,Goldenrod,IndianRed,CadetBlue,DarkSeaGreen,khaki,CornflowerBlue,orange"
|
||||
theme_blay="lavender,DimGray,SlateGray,LightSlateGray,LightSteelBlue,SkyBlue,CornflowerBlue,SteelBlue"
|
||||
themes="`set | grep "^theme_" | cut -f1 -d= | cut -c7- | tr '\n' ' '`"
|
||||
RSH="ssh"
|
||||
HOST=""
|
||||
USER=""
|
||||
|
||||
# if cols > 0, we arange the possitions of the xterms in $cols columns
|
||||
cols=0
|
||||
COLS=0
|
||||
hoffset=64
|
||||
voffset=64
|
||||
width=499
|
||||
@@ -31,20 +29,18 @@ space=4
|
||||
|
||||
|
||||
### functions ###
|
||||
print_version()
|
||||
{
|
||||
echo "$version"
|
||||
print_version() {
|
||||
echo "$VERSION"
|
||||
}
|
||||
|
||||
print_help()
|
||||
{
|
||||
cat <<EOH
|
||||
print_help() {
|
||||
cat <<EOH
|
||||
|
||||
Usage: xtermmaker.sh [-n <number>] [-C <columns>] [-u <user>] [-r <host>]
|
||||
[-c <color>] [-g] [-b] [-z] [-t <theme>]
|
||||
[-h,--help] [-V,--version]
|
||||
[-c <color>] [-g] [-b] [-z] [-t <theme>] [-p <preset>]
|
||||
[-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.
|
||||
|
||||
-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.
|
||||
-z Generates 'Bunte XTerms' in random sequence (default).
|
||||
-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
|
||||
}
|
||||
|
||||
rand()
|
||||
{
|
||||
rand() {
|
||||
# Usage: rand <int>
|
||||
local m="${1:-1}"
|
||||
local f="/dev/urandom"
|
||||
@@ -72,9 +75,72 @@ rand()
|
||||
|
||||
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
|
||||
while test $# -gt 0 ; do
|
||||
@@ -88,73 +154,116 @@ while test $# -gt 0 ; do
|
||||
exit 0
|
||||
;;
|
||||
-n|-number|--number)
|
||||
many="$2"
|
||||
NUMBER="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-C|-cols|--cols)
|
||||
cols="$2"
|
||||
COLS="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-c|-color|--color)
|
||||
color="$2"
|
||||
COLOR="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-g)
|
||||
color=Gray
|
||||
COLOR=Gray
|
||||
shift
|
||||
;;
|
||||
-b)
|
||||
color=BUNT
|
||||
COLOR=BUNT
|
||||
shift
|
||||
;;
|
||||
-z)
|
||||
color=RAND
|
||||
COLOR=RAND
|
||||
shift
|
||||
;;
|
||||
-t|-theme|--theme)
|
||||
theme="$2"
|
||||
THEME="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-p|-preset|--preset)
|
||||
PRESET="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-u|-user|--user)
|
||||
user="$2"
|
||||
USER="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-r|-host|--host)
|
||||
host="$2"
|
||||
HOST="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-w)
|
||||
if test -x "`which wterm`" ; then
|
||||
XTERM="wterm"
|
||||
XTERM_OPTS="$XTERM_OPTS -tr -sh"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
-|--)
|
||||
shift
|
||||
XTRA_OPTS=$@
|
||||
break
|
||||
;;
|
||||
esac
|
||||
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
|
||||
column=1
|
||||
hpos="$hoffset"
|
||||
vpos="$voffset"
|
||||
|
||||
eval colors=\$theme_$theme
|
||||
eval colors="\"\${THEME_${THEME}%,}\""
|
||||
ncolors="`echo \"$colors\" | tr -d [[:alnum:]]`"
|
||||
ncolors="${#ncolors}"
|
||||
ncolors="`expr $ncolors + 1`"
|
||||
|
||||
eval presets="\"\${PRESET_${PRESET}}\""
|
||||
npresets="`echo \"$presets\" | wc -l`"
|
||||
npresets="`expr $npresets - 1`"
|
||||
|
||||
xterm_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"
|
||||
|
||||
case "$color" in
|
||||
case "$COLOR" in
|
||||
NONE)
|
||||
;;
|
||||
BUNT)
|
||||
bg_opt="-bg `echo $colors | cut -f $color_count -d ,`"
|
||||
fg_opt="-fg ${FG_COLOR-black}"
|
||||
if test "$color_count" -lt "$ncolors" ; then
|
||||
color_count=`expr $color_count + 1`
|
||||
else
|
||||
@@ -164,20 +273,20 @@ until test $xterm_count -gt $many ; do
|
||||
RAND)
|
||||
color_count=`rand $ncolors`
|
||||
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
|
||||
|
||||
fg_opt="-fg black"
|
||||
|
||||
if test "$cols" -gt 0 ; then
|
||||
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
|
||||
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`"
|
||||
@@ -192,13 +301,16 @@ until test $xterm_count -gt $many ; do
|
||||
pos_opt=""
|
||||
fi
|
||||
|
||||
if test "$host" ; then
|
||||
t=$host
|
||||
test "$user" && t="${user}@${host}"
|
||||
exec_opt="-e $rsh $t"
|
||||
if test "X${HOST}" != "X" ; then
|
||||
t="$HOST"
|
||||
if test "X${USER}" != "X" ; then
|
||||
t="${USER}@${HOST}"
|
||||
fi
|
||||
exec_opt="-e $RSH $t"
|
||||
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`
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user