#!/bin/sh
# 
#	Script to transfer AfterStep 1.4+ look.file to
#	AfterStep 1.5pre+ format.  As always verify the results
#	prior to deletion of original files.
#	No, I will not be held responsible for anything this 
#	script might do as is or if modified.
#	
#	Release: version 1.0b July 15, 1998
#		Modified: to v1.1 July 27, 1998
#		  o changed version backward compatiblity # abv.
#		  o clarified what TextStyle is below.
#		Modified: to v1.2 August 6, 1998
#		  o added comments to help understand what changes what
#		Modified: to v1.3 December 10,1998
#		  o a simple address change for my site.
#	
#	Modifications to this script are encouraged; however I
#	simply ask that those that are made are forwarded to
#	myself (davemann@ionet.net) for inclusion for future
#	releases. Thanks :)
#	New version can be found at:
#		www.the-site.loonybin.net/Linux/AfterStep/
#		ftp.the-site.loonybin.net/pub/Linux/AfterStep/
#		{ soon to be [www. || ftp. ]the-site.org/ }
#
#	Usage: ./look.script look.old >look.new
#		(don't forget to make this script +x)
#
OLD=$1
TMP=look.tmp
sed 's/\	\	*/  /g' $OLD > $TMP

echo "####################" 
echo "# Look by Script v1.2" 
echo "#"
echo "--------------------"
echo
echo "# 1) Styles :"
echo "#"
echo '# If there is a style named "default" and no default style is specified, '
echo '# the "default" style will be used as the default'
echo "# Inherited styles will override options."
echo
echo "# default should never be used, so let's make it obvious when it *is* used"

# DEFAULT
echo 'MyStyle "default"'
sed -n "s/^Font  * \(-.*$\)/  Font\	\	\1/p" $TMP
echo " Used when ForeColor is needed and not defined"
sed -n "s/^StdForeColor *\(.*\)/  ForeColor\	\1/p" $TMP
echo " Used when BackColor is needed and not defined"
sed -n "s/^StdBackColor *\(.*\)/  BackColor\	\1/p" $TMP
echo '  ~MyStyle'
echo

#		COLORS
# FOCUS
f_type="" f_color="" f_pix=""
echo  'MyStyle "focus_colors"'
echo "# "
echo "# ForeColor - focused window text"
echo "# ForeColor == text foreground & icon backgound."
sed -n "s/^HiForeColor *\(.*\)/  ForeColor\	\1/p" $TMP
echo "# BackColor == titlebar foreground."
sed -n "s/^HiBackColor *\(.*\)/  BackColor\	\1/p" $TMP
echo "# refer 2) Textures."
sed -n "s/^TextureMaxColors  *\([0-9]*\)  *.*/  MaxColors\	\1/p" $TMP
f_type=`sed -n "s/^TextureTypes  *\([0-9]*\)  *.*/\1/p" $TMP`
if grep "^TitleTextureColor" $TMP >/dev/null
  then
    f_color=`sed -n "s/^TitleTextureColor  *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "# BackGradient == gradient of titlebar, refer 2) Textures."
    echo "  BackGradient	$f_type	$f_color"
  else
    f_pix=`sed -n "s/^TitlePixmap  *\(.*\)/\1/p" $TMP`
    echo "# BackPixmap == the pixmap for titlebar."
    echo "  BackPixmap	$f_type	$f_pix"
fi
echo '  ~MyStyle'
echo

# UNFOCUS
u_type="" u_color="" u_pix=""
echo  'MyStyle "unfocus_colors"'
echo "# ForeColor == text foreground."
sed -n "s/^StdForeColor *\(.*\)/  ForeColor\	\1/p" $TMP
echo "# BackColor == titlebar foreground"
sed -n "s/^StdBackColor *\(.*\)/  BackColor\	\1/p" $TMP
echo "# refer 2) Textures."
sed -n "s/^TextureMaxColors  *[0-9]*  *\([0-9]*\)  *.*/  MaxColors\	\1/p" $TMP
u_type=`sed -n "s/^TextureTypes  *[0-9]*  *\([0-9]*\)  *.*/\1/p" $TMP`
if grep "^UTitleTextureColor" $TMP >/dev/null
  then
    u_color=`sed -n "s/^UTitleTextureColor *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "# BackGradient == gradient of titlebar, refer 2) Textures."
    echo "  BackGradient	$u_type	$u_color"
  else
    u_pix=`sed -n "s/^UTitlePixmap  *\(.*\)/\1/p" $TMP`
    echo "# BackPixmap == the pixmap for titlebar."
    echo "  BackPixmap	$u_type	$u_pix"
fi
echo '  ~MyStyle'
echo

# STICKY
s_type="" s_color="" s_pix=""
echo 'MyStyle "sticky_colors"'
echo "# ForeColor == text foreground."
sed -n "s/^StickyForeColor  *\(.*\)/  ForeColor\	\1/p" $TMP
echo "# BackColor == titlebar foreground"
sed -n "s/^StickyBackColor *\(.*\)/  BackColor\	\1/p" $TMP
echo "# refer 2) Textures."
sed -n "s/^TextureMaxColors  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/  MaxColors\	\1/p" $TMP
s_type=`sed -n "s/^TextureTypes  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/\1/p" $TMP`
if grep "^STitleTextureColor" $TMP >/dev/null
  then
    s_color=`sed -n "s/^STitleTextureColor  *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "# BackGradient == gradient of titlebar, refer 2) Textures."
    echo "  BackGradient	$s_type	$s_color"
  else
    s_pix=`sed -n "s/^STitlePixmap  *\(.*\)/\1/p" $TMP`
    echo "# BackPixmap == the pixmap for titlebar."
    echo "  BackPixmap	$s_type	$s_pix"
fi
echo '  ~MyStyle'
echo

#		FONT
# WINDOW
echo 'MyStyle "window_font"'
sed -n "s/^WindowFont  * \(-.*$\)/  Font\	\	\1/p" $TMP
echo "  Inherit	focus_colors"
echo "# refer 3) Text below."
echo "  TextStyle	0"
echo "  ~MyStyle"
echo

# MENU
echo 'MyStyle "menu_font"'
sed -n "s/^Font  * \(-.*$\)/  Font\	\	\1/p" $TMP
echo "# refer 3) below for options"
echo "  TextStyle	0"
echo "# ForeColor == background for 3D text"
echo "#  ForeColor	"
echo "# BackColor == menu"
echo "#  BackColor	"
echo "  ~MyStyle"
echo

#		STYLE
# FOCUSED
echo 'MyStyle "focused_window_style"'
echo "  Inherit	window_font"
echo "  Inherit	focus_colors"
echo "  ~MyStyle"
echo

# UNFOCUSED
echo 'MyStyle "unfocused_window_style"'
echo "  Inherit	window_font"
echo "  Inherit	unfocus_colors"
echo "  ~MyStyle"
echo

# STICKY
echo 'MyStyle "sticky_window_style"'
echo "  Inherit	window_font"
echo "  Inherit	sticky_colors"
echo "  ~MyStyle"
echo

#		MENU
# TITLE
t_type="" t_color="" t_pix=""
echo 'MyStyle "menu_title_style"'
echo "  Inherit	focused_window_style"
echo "  Inherit	menu_font"
echo "#  Font		could be defined here!"
echo "# refer 3) below for options"
echo "   TextStyle	2"
sed -n "s/^TextureMaxColors  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/  MaxColors\	\1/p" $TMP
if grep "^MTitleForeColor" $TMP >/dev/null
  then
    sed -n "s/^MTitleForeColor  *\(.*\)/  ForeColor\	\1/p" $TMP
    sed -n "s/^MTitleBackColor  *\(.*\)/  BackColor\	\1/p" $TMP
  else
    echo "  Inherit	focused_colors"
fi
t_type=`sed -n "s/^TextureTypes  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/\1/p" $TMP`
if grep "^MTitleTextureColor" $TMP >/dev/null
  then
    t_color=`sed -n "s/^MTitleTextureColor  *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "  BackGradient	$t_type	$t_color"
  else
    t_pix=`sed -n "s/^MTitlePixmap  *\(.*\)/\1/p" $TMP`
    echo "  BackPixmap	$t_type	$t_pix"
fi
echo "  ~MyStyle"
echo

# ITEM
i_type="" i_color="" i_pix=""
echo 'MyStyle "menu_item_style"'
echo "  Inherit	menu_font"
echo "#  Font		could be defined here!"
echo "# refer 3) Text."
echo "  TextStyle	0"
sed -n "s/^TextureMaxColors  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/  MaxColors\	\1/p" $TMP
if grep "^MenuForeColor" $TMP >/dev/null
  then
    echo "# ForeColor == foreground text."
    sed -n "s/^MenuForeColor *\(.*\)/  ForeColor\	\1/p" $TMP
    echo "BackColor == background text (3D)."
    sed -n "s/^MenuBackColor *\(.*\)/  BackColor\	\1/p" $TMP
  else
    echo "  Inherit	focused_colors"
fi
i_type=`sed -n "s/^TextureTypes  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\)  *.*/\1/p" $TMP`
if grep "^MenuTextureColor" $TMP >/dev/null
  then
    i_color=`sed -n "s/^MenuTextureColor  *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "# BackPixmap == TextureType  from  to."
    echo "  BackGradient	$i_type	$i_color"
  else
    i_pix=`sed -n "s/^MenuPixmap  *\(.*\)/\1/p" $TMP`
    echo "# BackPixmap == TextureType  pixmap"
    echo "  BackPixmap	$i_type	$i_pix"
fi
echo "  ~MyStyle"
echo

# HILITE
h_type="" h_color="" h_pix=""
echo 'MyStyle "menu_hilite_style"'
echo "  Inherit	menu_font"
echo "#  Font		could be defined here!"
echo "# refer 3) Text."
echo "  TextStyle	0"
echo "# ForeColor == hilight text color."
sed -n "s/^MenuHiForeColor *\(.*\)/  ForeColor\	\1/p" $TMP
echo "# BackColor == hilight text color (3D)."
sed -n "s/^MenuHiBackColor *\(.*\)/  BackColor\	\1/p" $TMP
sed -n "s/^TextureMaxColors  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\).*/  MaxColors\	\1/p" $TMP
h_type=`sed -n "s/^TextureTypes  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *[0-9]*  *\([0-9]*\).*/\1/p" $TMP`
if grep "^MenuHiTextureColor" $TMP >/dev/null
  then
    h_color=`sed -n "s/^MenuHiTextureColor  *\(#*[0-9a-z]*\)  *\(#*[0-9a-z]*\)/\1 \2/p" $TMP`
    echo "# BackGradient == TextureType  from  to."
    echo "  BackGradient	$h_type	$h_color"
  else
    h_pix=`sed -n "s/^MenuPixmap  *\(.*\)/\1/p" $TMP`
    echo "# BackPixmap == TextureType  pixmap"
    echo "  BackPixmap	$h_type	$h_pix"
fi
echo "  ~MyStyle"
echo

# STIPPLE
echo "# make the stipple background the same as the menu item, or "
echo "# strange border drawing artifacts could occur."
echo 'MyStyle	"menu_stipple_style"'
echo "  Inherit	menu_item_style"
echo "# new feature to be added soon:"
echo "#  ForeStipple	stipple.xpm"
echo "  ~MyStyle"
echo

#		REITERATE
echo 'DefaultStyle		"default"'
echo 'FWindowStyle		"focused_window_style"'
echo 'UWindowStyle		"unfocused_window_style"'
echo 'SWindowStyle		"sticky_window_style"'
echo 'MenuItemStyle		"menu_item_style"'
echo 'MenuTitleStyle		"menu_title_style"'
echo 'MenuHiliteStyle		"menu_hilite_style"'
echo 'MenuStippleStyle	"menu_stipple_style"'
echo

#		LEFTOVER
echo "# 2) Textures : avoid them on 8bpp !"
echo 
echo "#   0 - No texture"
echo "#   1 - Wharf-style gradient                            ^-"
echo "#   2 - Horizontal one way gradient                     ¯-_"
echo "#   3 - Horizontal from top/bottom to center            =-="
echo "#   4 - Vertical one way gradient from left to right    ||| | |  | |"
echo "#   5 - Vertical from left/right to center              >>>>>><<<<<<"
echo "# 128 - User defined pixmap"
echo "# 129 - User defined pixmap for the whole menu (must be 128) & menutitle (129)"
echo "# 130 - Transparent menu (must be 128) & menutitle (130)"
echo 
echo "# 2-1) : types"
grep ButtonTextureType $TMP
echo
echo "# 2-2) : max colors"
echo "# Number of colors : default is 10 on 8bpp screens, 32 on 16 bpp and 128 on 32"
grep ButtonMaxColors $TMP
echo
echo "# 2-3) : pixmaps"
grep ButtonPixmap $TMP
grep MArrowPixmap $TMP
echo "# New Features - adjust xpm to taste"
echo "MenuPinOn		as-kill.xpm"
echo "MenuPinOff		as-kill-pressed.xpm"
echo
echo "# 2-4) : gradients (can't choose both, except for TextGradientColor)"
grep ButtonTextureColor $TMP
grep ButtonBgColor $TMP
echo
echo "# 2-5) : misc options"
echo "#  Textures/Pixmaps on windows lowbar ?"
grep TexturedHandle $TMP
echo "#  Gradient on windows title ?"
grep GradientText $TMP
echo "#  Border around iconifyied windows ?"
grep ButtonNoBorder $TMP
echo "#  Draw lines between menu options ?"
grep DrawMenuBorders $TMP
echo "#  Texture menu options individually, or the whole menu ?"
grep TextureMenuItemsIndividually $TMP
echo
echo "# 3) Text :"
echo "#    TitleTextMode == TextStyle in above _style's"
echo "#  Mode is either 0 (normal), 1 (big 3d), 2 (nice 3d); Z is title height"
grep "TitleTextMode" $TMP
echo "#  Corner where the resize box goes to : ++, +-, -+, -- (clockwise)"
grep ResizeMoveGeometry $TMP
echo
echo "# 3-1) Text : fonts"
sed -n "s/^Font  * \(-.*$\)/Font\	\	\1/p" $TMP
sed -n "s/^WindowFont  * \(-.*$\)/WindowFont\	\1/p" $TMP
sed -n "s/^IconFont  * \(-.*$\)/IconFont\	\1/p" $TMP
grep IconBox $TMP
grep TitleTextAlign $TMP
grep TitlebarNoPush $TMP
echo
grep TitleButton $TMP
echo "#EOF"

# CLEANUP
rm -f $TMP
