#!/bin/sh
# JWM Theme Builder 1.0  (module of JWMdesk)
# Copyright 2022 GPL3 http://www.gnu.org/licenses
# Author: Roger D. Grider (radky)
# Based on JWM Theme Maker by Trio

export TEXTDOMAIN=jwmdesk
export OUTPUT_CHARSET=UTF-8
. gettext.sh

export APPDIR=/usr/local/jwmdesk
export ICONDIR=$APPDIR/icons
export PREFDIR=$APPDIR/.jcc/builder
mkdir -p $PREFDIR

# check if JWM version >= 2.3.6, otherwise abort
JWM_VER_OK="false"
JWM_VER=$(jwm -v | head -n1 | cut -d " " -f2- | cut -d " " -f1 | sed -e 's/[snvgit-]//g')
if [ "`jwm -v | head -n1 | grep -aE 'vgit|vsvn' 2>/dev/null`" ]; then
	if ((`bc <<< "$JWM_VER>=1485"`)); then # JWM >= snapshot 1485
	 JWM_VER_OK="true"
	fi
else
	if [ "`echo "$JWM_VER" | grep -aE '^2\.3\.[6-9]|^2\.[4-9]|^[3-9]' 2>/dev/null`" ]; then # JWM >= 2.3.6
	 JWM_VER_OK="true"
	fi
fi

[ "$JWM_VER_OK" = "false" ] && gtkdialog-splash -close never -wrap false -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'JWM Theme Builder requires JWM >= 2.3.6 !') " && exit 0 # abort

gtkdialog-splash -close never -margin 8 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Processing...') " &
splashPID=$!

# define theme directory
[ -d /usr/local/jwm_config* ] && THEMEDIR="/usr/share/jwm/themes" || THEMEDIR="$HOME/.jwm/themes"
[ ! -d "$THEMEDIR" ] && THEMEDIR="/usr/share/jwm/themes"
export THEMEDIR

# define gtkdialog
[ "`which gtkdialog4 2>/dev/null`" ] && GTKDIALOG=gtkdialog4 || GTKDIALOG=gtkdialog
if [ "`which gtk2dialog 2>/dev/null`" ]; then
	gtk2_dialog=$(cat $APPDIR/.jcc/gtk2-dialog 2>/dev/null)
	[ ! "$gtk2_dialog" ] && gtk2_dialog="true" && echo "$gtk2_dialog" > $APPDIR/.jcc/gtk2-dialog
	[ "$gtk2_dialog" = "true" ] && GTKDIALOG=gtk2dialog
fi
export GTKDIALOG

# define title-bar icon
[ ! -f /usr/share/icons/hicolor/48x48/apps/theme_builder.svg ] && \
ln -sf /usr/local/jwmdesk/icons/theme_builder.svg /usr/share/icons/hicolor/48x48/apps && gtk-update-icon-cache -f -i /usr/share/icons/hicolor 2>/dev/null

# define GUI header
XML_INFO_COLOR='#EDEBD7' # background color
XML_INFO_OPACITY=0.5 # background opacity
. $APPDIR/xml_info_jwmdesk gtk > /dev/null # build bg_pixmap for gtk-theme

BOX_HEIGHT=90
ICON=$ICONDIR/theme_builder.svg
ICON_HEIGHT=70
MSG_1="<b><span size='"'x-large'"'>$(gettext "JWM Theme Builder")</span></b>"
MSG_2="<b>$(gettext "Create or edit JWM themes")</b>"
ALIGN=center # center or left
HEADER="
	<hbox height-request="'"${BOX_HEIGHT}"'" space-expand=\"false\" space-fill=\"true\">
	$(. $APPDIR/xml_info_jwmdesk "$ICON" "$ICON_HEIGHT" "$MSG_1" "$MSG_2" "$ALIGN")
	</hbox>"

# remove GUI header for small screens
CURRDPI=`grep -a "^Xft\\.dpi:" $HOME/.Xresources 2>/dev/null | tr '\t' ' ' | tr -s ' ' | cut -f 2 -d ' '`
[ ! "$CURRDPI" ] && CURRDPI="120"
STYLE="/tmp/jwmdesk/gtkrc_xml_info.css"

if [ "`which xwininfo 2>/dev/null`" ]; then # X11
   read ROOTDIMS MX MY << EOF
`xwininfo -root | grep -F ' -geometry ' | cut -f 1 -d '+' | tr 'x' ' '`
EOF

elif [ "`which wlr-randr 2>/dev/null`" ]; then # Wayland
   read MX MY << EOF
`wlr-randr | grep -m1 'current' | awk '{print $1}' | tr 'x' ' '`
EOF

fi

if [ "$MY" -lt "1024" ]; then
	if [ "$CURRDPI" -gt "120" ]; then
		HEADER="<text use-markup=\"true\" homogeneous=\"true\" space-expand=\"false\" space-fill=\"true\"><label>\"<b><span size='"'medium'"'>$(gettext 'JWM Theme Builder')</span></b>\"</label></text>"
		STYLE="/tmp/jwmdesk/gtkrc.css"
	fi
fi

# define GUI width and desktop position
export gui_width=650
GEO=+$((($MX/2)-$((($gui_width+30)/2))))+$((($MY/2)-360))
[ ! "$GEO" ] && GEO=+50+50
export GEO

########################################################################
#                                                                      #
# FUNCTIONS                                                            #
#                                                                      #
########################################################################

checkname ()
{
[ -z "$NEWTHEME" ] && gtkdialog-splash -close never -wrap false -timeout 4 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please enter new theme name !') " && exit 0
[ "$NEWTHEME" = "Base template" -o "$NEWTHEME" = "Light template" -o "$NEWTHEME" = "Dark template" ] && gtkdialog-splash -close never -wrap false -timeout 4 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please change theme name !') " && exit 0

NEWTHEME=$(basename "$NEWTHEME" | sed -e 's/-jwmrc$//' -e 's/ /_/g' -e 's/[!#$%*@]//g')

if [ -f "$THEMEDIR/$NEWTHEME-jwmrc" ]; then
	[ "`ldd $(which gtkdialog) | grep -Fi 'gtk-3' 2>/dev/null`" ] && bw="100" || bw="70"
	Xdialog --title "$(gettext 'Alert')" --backtitle "$NEWTHEME-jwmrc $(gettext 'already exists')"  --stdout --center --yesno  "$(gettext 'Overwrite existing theme ?')" 10 $bw
	case $? in
	0)
		savetheme &
		;;
	1)
		exit 0
		;;
	esac
	exit 0
else
	savetheme &
	exit 0
fi
}
export -f checkname

edittheme ()
{
	[ -z "$NEWTHEME" ] && gtkdialog-splash -close never -wrap false -timeout 3 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please select a theme !') " && $APPDIR/theme_builder && exit 0
	[[ $(echo "$NEWTHEME" | grep '^ ') ]] && gtkdialog-splash -close never -wrap false -timeout 3 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please select a theme !') " && $APPDIR/theme_builder && exit 0

[ "$NEWTHEME" = "Base template" -o "$NEWTHEME" = "Light template" -o "$NEWTHEME" = "Dark template" ] && gtkdialog-splash -close never -wrap false -timeout 4 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please change theme name !') " && $APPDIR/theme_builder && exit 0

	NEWTHEME=$(echo "$NEWTHEME" | sed 's/-jwmrc$//g')

	if [[ $(echo "$NEWTHEME" | grep '\/') ]]; then
		[ ! -f "$NEWTHEME-jwmrc" ] && gtkdialog-splash -close never -wrap false -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $NEWTHEME-jwmrc $(gettext 'not found') ! " && $APPDIR/theme_builder && exit 0
		I="$NEWTHEME"
	else
		[ ! -f "$THEMEDIR/$NEWTHEME-jwmrc" ] && gtkdialog-splash -close never -wrap false -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $NEWTHEME-jwmrc $(gettext 'not found in') $THEMEDIR ! " && $APPDIR/theme_builder && exit 0
		I="$THEMEDIR/$NEWTHEME"
	fi

	gtkdialog-splash -close never -timeout 3 -margin 8 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Processing...') " &

	rm -f $PREFDIR/*

	# define color styles of template theme

	# window
	[[ $(grep -E '<<|>>' "${I}-jwmrc" 2>/dev/null) ]] && sed -i -e 's/<</</g' -e 's/>>/>/g' "${I}-jwmrc"
	active_primary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	active_secondary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	active_window_fg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

	inactive_primary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	inactive_secondary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	if [ ! "$inactive_primary_window_bg" ]; then
		inactive_primary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FA 100 '<WindowStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		inactive_secondary_window_bg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FA 100 '<WindowStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	fi

	inactive_window_fg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$inactive_window_fg" ]; then
		inactive_window_fg="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FA 100 '<WindowStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	fi

	active_window_border="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	inactive_window_border="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FB 100 '</WindowStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$active_window_border" ]; then
		active_window_border="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -FA 100 '<WindowStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	fi

	window_titlebar_height="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Height>' | awk -F'Height>' '{print $2}' | cut -d'<' -f1)"
	[ ! "$window_titlebar_height" ] && window_titlebar_height="22"
	window_border_width="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Width>' | awk -F'Width>' '{print $2}' | cut -d'<' -f1)"
	[ ! "$window_border_width" ] && window_border_width="4"
	window_corner_radius="$(sed -n '/<WindowStyle>/,/<\/WindowStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Corner>' | awk -F'Corner>' '{print $2}' | cut -d'<' -f1)"
	[ ! "$window_corner_radius" ] && window_corner_radius="3"
	# menu
	active_primary_menu_bg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	active_secondary_menu_bg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	active_menu_fg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

	inactive_primary_menu_bg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	if [ ! "$inactive_primary_menu_bg" ]; then
		inactive_primary_menu_bg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FA 100 '<MenuStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	fi

	inactive_menu_fg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$inactive_menu_fg" ]; then
		inactive_menu_fg="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FA 100 '<MenuStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	fi

	inactive_menu_border="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FB 100 '</MenuStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$active_menu_border" ]; then
		active_menu_border="$(sed -n '/<MenuStyle>/,/<\/MenuStyle>/p' "${I}-jwmrc" | grep -FA 100 '<MenuStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	fi
	# tray
	active_primary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	active_secondary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	active_tray_fg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

	inactive_primary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	inactive_secondary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	if [ ! "$inactive_primary_tray_bg" ]; then
		inactive_primary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	fi
	if [ ! "$inactive_secondary_tray_bg" ]; then
		inactive_secondary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	fi
	[ ! "$inactive_primary_tray_bg" ] && inactive_primary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	[ ! "$inactive_secondary_tray_bg" ] && inactive_secondary_tray_bg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"

	inactive_tray_fg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$inactive_tray_fg" ]; then
		inactive_tray_fg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	fi
	[ ! "$inactive_tray_fg" ] && inactive_tray_fg="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"

	inactive_tray_border="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$inactive_tray_border" ]; then
		inactive_tray_border="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	fi
	[ ! "$inactive_tray_border" ] && inactive_tray_border="$(sed -n "/<TrayStyle>/,/<\/TrayStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	# task list
	if [[ $(grep '<TaskListStyle>' "${I}-jwmrc" 2>/dev/null) ]]; then
		active_primary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		active_secondary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		active_tasklist_fg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

		inactive_primary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		inactive_secondary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		if [ ! "$inactive_primary_tasklist_bg" ]; then
			inactive_primary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TaskListStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		fi
		if [ ! "$inactive_secondary_tasklist_bg" ]; then
			inactive_secondary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TaskListStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		fi
		[ ! "$inactive_primary_tasklist_bg" ] && inactive_primary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		[ ! "$inactive_secondary_tasklist_bg" ] && inactive_secondary_tasklist_bg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"

		inactive_tasklist_fg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
		if [ ! "$inactive_tasklist_fg" ]; then
			inactive_tasklist_fg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TaskListStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
		fi
		[ ! "$inactive_tasklist_fg" ] && inactive_tasklist_fg="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"

		inactive_tasklist_border="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TaskListStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
		if [ ! "$inactive_tasklist_border" ]; then
			inactive_tasklist_border="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TaskListStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
		fi
		[ ! "$inactive_tasklist_border" ] && inactive_tasklist_border="$(sed -n "/<TaskListStyle>/,/<\/TaskListStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"

		[ ! "$active_primary_tasklist_bg" ] && active_primary_tasklist_bg="$active_primary_tray_bg"
		[ ! "$active_secondary_tasklist_bg" ] && active_secondary_tasklist_bg="$active_secondary_tray_bg"
		[ ! "$active_tasklist_fg" ] && active_tasklist_fg="$active_tray_fg"
		[ ! "$inactive_primary_tasklist_bg" ] && inactive_primary_tasklist_bg="$inactive_primary_tray_bg"
		[ ! "$inactive_secondary_tasklist_bg" ] && inactive_secondary_tasklist_bg="$inactive_secondary_tray_bg"
		[ ! "$inactive_tasklist_fg" ] && inactive_tasklist_fg="$inactive_tray_fg"
		[ ! "$inactive_tasklist_border" ] && inactive_tasklist_border="$inactive_tray_border"
		[ ! "$inactive_tasklist_border" ] && inactive_tasklist_border="#000000"

		[ ! "$active_primary_tray_bg" ] && active_primary_tray_bg="$active_primary_tasklist_bg"
		[ ! "$active_secondary_tray_bg" ] && active_secondary_tray_bg="$active_secondary_tasklist_bg"
		[ ! "$active_tray_fg" ] && active_tray_fg="$active_tasklist_fg"
		[ ! "$inactive_primary_tray_bg" ] && inactive_primary_tray_bg="$inactive_primary_tasklist_bg"
		[ ! "$inactive_secondary_tray_bg" ] && inactive_secondary_tray_bg="$inactive_secondary_tasklist_bg"
		[ ! "$inactive_tray_fg" ] && inactive_tray_fg="$inactive_tasklist_fg"
		[ ! "$inactive_tray_border" ] && inactive_tray_border="$inactive_tasklist_border"
	else
		active_primary_tasklist_bg=$active_primary_tray_bg
		active_secondary_tasklist_bg=$active_secondary_tray_bg
		active_tasklist_fg=$active_tray_fg
		inactive_primary_tasklist_bg=$inactive_primary_tray_bg
		inactive_secondary_tasklist_bg=$inactive_secondary_tray_bg
		inactive_tasklist_fg=$inactive_tray_fg
		inactive_tasklist_border=$inactive_tray_border
	fi
	# tray button
	if [[ $(grep '<TrayButtonStyle>' "${I}-jwmrc" 2>/dev/null) ]]; then
		active_primary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		active_secondary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		active_traybutton_fg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

		inactive_primary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		inactive_secondary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		if [ ! "$inactive_primary_traybutton_bg" ]; then
			inactive_primary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayButtonStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		fi
		if [ ! "$inactive_secondary_traybutton_bg" ]; then
			inactive_secondary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayButtonStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
		fi
		[ ! "$inactive_primary_traybutton_bg" ] && inactive_primary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
		[ ! "$inactive_secondary_traybutton_bg" ] && inactive_secondary_traybutton_bg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"

		inactive_traybutton_fg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
		if [ ! "$inactive_traybutton_fg" ]; then
			inactive_traybutton_fg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayButtonStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
		fi
		[ ! "$inactive_traybutton_fg" ] && inactive_traybutton_fg="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"

		inactive_traybutton_border="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FB 100 '</TrayButtonStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
		if [ ! "$inactive_traybutton_border" ]; then
			inactive_traybutton_border="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -FA 100 '<TrayButtonStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
		fi
		[ ! "$inactive_traybutton_border" ] && inactive_traybutton_border="$(sed -n "/<TrayButtonStyle>/,/<\/TrayButtonStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"

		[ ! "$active_primary_traybutton_bg" ] && active_primary_traybutton_bg="$active_primary_tray_bg"
		[ ! "$active_secondary_traybutton_bg" ] && active_secondary_traybutton_bg="$active_secondary_tray_bg"
		[ ! "$active_traybutton_fg" ] && active_traybutton_fg="$active_tray_fg"
		[ ! "$inactive_primary_traybutton_bg" ] && inactive_primary_traybutton_bg="$inactive_primary_tray_bg"
		[ ! "$inactive_secondary_traybutton_bg" ] && inactive_secondary_traybutton_bg="$inactive_secondary_tray_bg"
		[ ! "$inactive_traybutton_fg" ] && inactive_traybutton_fg="$inactive_tray_fg"
		[ ! "$inactive_traybutton_border" ] && inactive_traybutton_border="$inactive_tray_border"
		[ ! "$inactive_traybutton_border" ] && inactive_traybutton_border="#000000"
	else
		active_primary_traybutton_bg=$active_primary_tray_bg
		active_secondary_traybutton_bg=$active_secondary_tray_bg
		active_traybutton_fg=$active_tray_fg
		inactive_primary_traybutton_bg=$inactive_primary_tray_bg
		inactive_secondary_traybutton_bg=$inactive_secondary_tray_bg
		inactive_traybutton_fg=$inactive_tray_fg
		inactive_traybutton_border=$inactive_tray_border
	fi
	# pager
	active_primary_pager_bg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FB 100 '</PagerStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	active_pager_fg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FB 100 '</PagerStyle>' | grep -Fm1 -A100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}'| cut -d'<' -f1)"

	inactive_primary_pager_bg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FB 100 '</PagerStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	if [ ! "$inactive_primary_pager_bg" ]; then
		inactive_primary_pager_bg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FA 100 '<PagerStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	fi

	inactive_pager_fg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FB 100 '</PagerStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$inactive_pager_fg" ]; then
		inactive_pager_fg="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FA 100 '<PagerStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	fi

	inactive_pager_border="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FB 100 '</PagerStyle>' | grep -Fm1 -B100 '<Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	if [ ! "$active_pager_border" ]; then
		active_pager_border="$(sed -n '/<PagerStyle>/,/<\/PagerStyle>/p' "${I}-jwmrc" | grep -FA 100 '<PagerStyle' | grep -Fm1 -A100 '</Active>' | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	fi
	# popup
	popup_bg="$(sed -n '/<PopupStyle>/,/<\/PopupStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d'<' -f1)"
	popup_fg="$(sed -n '/<PopupStyle>/,/<\/PopupStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	popup_border="$(sed -n '/<PopupStyle>/,/<\/PopupStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Outline>' | awk -F'Outline>' '{print $2}' | cut -d'<' -f1)"
	# clock
	primary_clock_bg="$(sed -n "/<ClockStyle>/,/<\/ClockStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f1 | cut -d'<' -f1)"
	[ ! "$primary_clock_bg" ] && primary_clock_bg="$inactive_primary_tray_bg"
	secondary_clock_bg="$(sed -n "/<ClockStyle>/,/<\/ClockStyle>/p" "${I}-jwmrc" | grep -Fm1 '<Background>' | awk -F'Background>' '{print $2}' | cut -d: -f2 | cut -d'<' -f1)"
	[ ! "$secondary_clock_bg" ] && secondary_clock_bg="$inactive_secondary_tray_bg"

	clock_fg="$(sed -n '/<ClockStyle>/,/<\/ClockStyle>/p' "${I}-jwmrc" | grep -Fm1 '<Foreground>' | awk -F'Foreground>' '{print $2}' | cut -d'<' -f1)"
	[ ! "$clock_fg" ] && clock_fg="$inactive_tray_fg"

	# save color styles of template theme to resource directory
	echo "$active_primary_window_bg" > $PREFDIR/active-primary-window-bg
	echo "$active_secondary_window_bg" > $PREFDIR/active-secondary-window-bg
	echo "$active_window_fg" > $PREFDIR/active-window-fg
	echo "$inactive_primary_window_bg" > $PREFDIR/inactive-primary-window-bg
	echo "$inactive_secondary_window_bg" > $PREFDIR/inactive-secondary-window-bg
	echo "$inactive_window_fg" > $PREFDIR/inactive-window-fg
	echo "$active_window_border" > $PREFDIR/active-window-border
	echo "$inactive_window_border" > $PREFDIR/inactive-window-border
	echo "$window_titlebar_height" > $PREFDIR/window-titlebar-height
	echo "$window_border_width" > $PREFDIR/window-border-width
	echo "$window_corner_radius" > $PREFDIR/window-corner-radius

	echo "$active_primary_menu_bg" > $PREFDIR/active-primary-menu-bg
	echo "$active_secondary_menu_bg" > $PREFDIR/active-secondary-menu-bg
	echo "$active_menu_fg" > $PREFDIR/active-menu-fg
	echo "$inactive_primary_menu_bg" > $PREFDIR/inactive-primary-menu-bg
	echo "$inactive_menu_fg" > $PREFDIR/inactive-menu-fg
	echo "$inactive_menu_border" > $PREFDIR/inactive-menu-border

	echo "$active_primary_tray_bg" > $PREFDIR/active-primary-tray-bg
	echo "$active_secondary_tray_bg" > $PREFDIR/active-secondary-tray-bg
	echo "$active_tray_fg" > $PREFDIR/active-tray-fg
	echo "$inactive_primary_tray_bg" > $PREFDIR/inactive-primary-tray-bg
	echo "$inactive_secondary_tray_bg" > $PREFDIR/inactive-secondary-tray-bg
	echo "$inactive_tray_fg" > $PREFDIR/inactive-tray-fg
	echo "$inactive_tray_border" > $PREFDIR/inactive-tray-border

	echo "$active_primary_traybutton_bg" > $PREFDIR/active-primary-traybutton-bg
	echo "$active_secondary_traybutton_bg" > $PREFDIR/active-secondary-traybutton-bg
	echo "$active_traybutton_fg" > $PREFDIR/active-traybutton-fg
	echo "$inactive_primary_traybutton_bg" > $PREFDIR/inactive-primary-traybutton-bg
	echo "$inactive_secondary_traybutton_bg" > $PREFDIR/inactive-secondary-traybutton-bg
	echo "$inactive_traybutton_fg" > $PREFDIR/inactive-traybutton-fg
	echo "$inactive_traybutton_border" > $PREFDIR/inactive-traybutton-border

	echo "$active_primary_tasklist_bg" > $PREFDIR/active-primary-tasklist-bg
	echo "$active_secondary_tasklist_bg" > $PREFDIR/active-secondary-tasklist-bg
	echo "$active_tasklist_fg" > $PREFDIR/active-tasklist-fg
	echo "$inactive_primary_tasklist_bg" > $PREFDIR/inactive-primary-tasklist-bg
	echo "$inactive_secondary_tasklist_bg" > $PREFDIR/inactive-secondary-tasklist-bg
	echo "$inactive_tasklist_fg" > $PREFDIR/inactive-tasklist-fg
	echo "$inactive_tasklist_border" > $PREFDIR/inactive-tasklist-border

	echo "$active_primary_pager_bg" > $PREFDIR/active-primary-pager-bg
	echo "$active_pager_fg" > $PREFDIR/active-pager-fg
	echo "$inactive_primary_pager_bg" > $PREFDIR/inactive-primary-pager-bg
	echo "$inactive_pager_fg" > $PREFDIR/inactive-pager-fg
	echo "$inactive_pager_border" > $PREFDIR/inactive-pager-border

	echo "$popup_bg" > $PREFDIR/popup-bg
	echo "$popup_fg" > $PREFDIR/popup-fg
	echo "$popup_border" > $PREFDIR/popup-border

	echo "$primary_clock_bg" > $PREFDIR/primary-clock-bg
	echo "$secondary_clock_bg" > $PREFDIR/secondary-clock-bg
	echo "$clock_fg" > $PREFDIR/clock-fg

	sleep .5

	# restart theme builder and retrieve color styles of template theme
	$APPDIR/theme_builder &
}
export -f edittheme

savetheme ()
{
gtkdialog-splash -close never -wrap false -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Saving to') $THEMEDIR/$NEWTHEME-jwmrc " &

active_menu_bg="$active_primary_menu_bg:$active_secondary_menu_bg"

active_window_bg="$active_primary_window_bg:$active_secondary_window_bg"
inactive_window_bg="$inactive_primary_window_bg:$inactive_secondary_window_bg"

active_tray_bg="$active_primary_tray_bg:$active_secondary_tray_bg"
inactive_tray_bg="$inactive_primary_tray_bg:$inactive_secondary_tray_bg"

active_traybutton_bg="$active_primary_traybutton_bg:$active_secondary_traybutton_bg"
inactive_traybutton_bg="$inactive_primary_traybutton_bg:$inactive_secondary_traybutton_bg"

active_tasklist_bg="$active_primary_tasklist_bg:$active_secondary_tasklist_bg"
inactive_tasklist_bg="$inactive_primary_tasklist_bg:$inactive_secondary_tasklist_bg"

clock_bg="$primary_clock_bg:$secondary_clock_bg"

theme_font_attributes=$(echo "$theme_font_attributes" | sed 's/ /:/g')
font="$theme_font_name-$theme_font_size:$theme_font_attributes"

	echo "<?xml version=\"1.0\"?>

<!-- Created by JWM Theme Builder -->
<!-- Format requires JWM >= 2.3.6 -->

<JWM>

<WindowStyle>
	<Font>$font</Font>
	<Width>$window_border_width</Width>
	<Height>$window_titlebar_height</Height>
	<Corner>$window_corner_radius</Corner>
	<Active>
		<Foreground>$active_window_fg</Foreground>
		<Background>$active_window_bg</Background>
		<Outline>$active_window_border</Outline>
	</Active>
	<Foreground>$inactive_window_fg</Foreground>
	<Background>$inactive_window_bg</Background>
	<Outline>$inactive_window_border</Outline>
</WindowStyle>

<TrayStyle>
	<Font>$font</Font>
	<Opacity>0.85</Opacity>
	<Foreground>$inactive_tray_fg</Foreground>
	<Background>$inactive_tray_bg</Background>
	<Outline>$inactive_tray_border</Outline>
	<Active>
		<Foreground>$active_tray_fg</Foreground>
		<Background>$active_tray_bg</Background>
	</Active>
</TrayStyle>

<TrayButtonStyle>
	<Font>$font</Font>
	<Foreground>$inactive_traybutton_fg</Foreground>
	<Background>$inactive_traybutton_bg</Background>
	<Outline>$inactive_traybutton_border</Outline>
	<Active>
		<Foreground>$active_traybutton_fg</Foreground>
		<Background>$active_traybutton_bg</Background>
	</Active>
</TrayButtonStyle>

<TaskListStyle>
	<Font>$font</Font>
	<Foreground>$inactive_tasklist_fg</Foreground>
	<Background>$inactive_tasklist_bg</Background>
	<Outline>$inactive_tasklist_border</Outline>
	<Active>
		<Foreground>$active_tasklist_fg</Foreground>
		<Background>$active_tasklist_bg</Background>
	</Active>
</TaskListStyle>

<PagerStyle>
	<Outline>$inactive_pager_border</Outline>
	<Foreground>$inactive_pager_fg</Foreground>
	<Background>$inactive_primary_pager_bg</Background>
	<Active>
		<Foreground>$active_pager_fg</Foreground>
		<Background>$active_primary_pager_bg</Background>
	</Active>
</PagerStyle>

<PopupStyle delay=\"500\">
	<Font>Sans-10</Font>
	<Outline>$popup_border</Outline>
	<Foreground>$popup_fg</Foreground>
	<Background>$popup_bg</Background>
</PopupStyle>

<MenuStyle>
	<Font>$font</Font>
	<Foreground>$inactive_menu_fg</Foreground>
	<Background>$inactive_primary_menu_bg</Background>
	<Outline>$inactive_menu_border</Outline>
	<Active>
		<Foreground>$active_menu_fg</Foreground>
		<Background>$active_menu_bg</Background>
	</Active>
</MenuStyle>

<ClockStyle>
	<Font>$font</Font>
	<Foreground>$clock_fg</Foreground>
	<Background>$clock_bg</Background>
</ClockStyle>

</JWM>
" > "$THEMEDIR/$NEWTHEME-jwmrc"

rm -f /tmp/newtheme 2>/dev/null
}
export -f savetheme

newtemplate ()
{
	[ "`ldd $(which gtkdialog) | grep -Fi 'gtk-3' 2>/dev/null`" ] && gw="85" || gw="60"
	Xdialog --title "Theme Templates" --radiolist "JWM Theme Templates" 13 $gw 5 "Base" " Flat Gray" off "Light" " Stardust Bright" off "Dark" " Stardust Dark" off 2>/tmp/radiolist.tmp.$$
	retval=$?
	choice=`cat /tmp/radiolist.tmp.$$`
	rm -f /tmp/radiolist.tmp.$$

	case $retval in
	0)
		echo "$choice" > /tmp/jwmtheme-template
		echo "$choice template" > /tmp/newtheme
		$APPDIR/theme_builder &
	;;
	1)
		echo "Cancel"
		$APPDIR/theme_builder &
	;;
	255)
		echo "Abort"
		$APPDIR/theme_builder &
	;;
	esac
	exit 0
}
export -f newtemplate

# theme templates
if [ -f /tmp/jwmtheme-template ]; then
	jwmtheme_template=$(cat /tmp/jwmtheme-template)
	rm -f /tmp/jwmtheme-template
	if [ "$jwmtheme_template" = "Base" ]; then # flat-gray
		echo "Sans" > $PREFDIR/theme-font-name
		echo "10" > $PREFDIR/theme-font-size
		echo "normal" > $PREFDIR/theme-font-attributes
		echo "22" > $PREFDIR/window-titlebar-height
		echo "4" > $PREFDIR/window-border-width
		echo "3" > $PREFDIR/window-corner-radius
		echo "#A9A9A9" > $PREFDIR/active-primary-window-bg
		echo "#A9A9A9" > $PREFDIR/active-secondary-window-bg
		echo "#D2D2D2" > $PREFDIR/inactive-primary-window-bg
		echo "#D2D2D2" > $PREFDIR/inactive-secondary-window-bg
		echo "#000000" > $PREFDIR/active-window-fg
		echo "#000000" > $PREFDIR/inactive-window-fg
		echo "#000000" > $PREFDIR/active-window-border
		echo "#000000" > $PREFDIR/inactive-window-border
		echo "#A9A9A9" > $PREFDIR/active-primary-menu-bg
		echo "#A9A9A9" > $PREFDIR/active-secondary-menu-bg
		echo "#DCDAD5" > $PREFDIR/inactive-primary-menu-bg
		echo "#000000" > $PREFDIR/active-menu-fg
		echo "#000000" > $PREFDIR/inactive-menu-fg
		echo "#000000" > $PREFDIR/inactive-menu-border
		echo "#A9A9A9" > $PREFDIR/active-primary-tray-bg
		echo "#A9A9A9" > $PREFDIR/active-secondary-tray-bg
		echo "#DCDAD5" > $PREFDIR/inactive-primary-tray-bg
		echo "#DCDAD5" > $PREFDIR/inactive-secondary-tray-bg
		echo "#000000" > $PREFDIR/active-tray-fg
		echo "#000000" > $PREFDIR/inactive-tray-fg
		echo "#000000" > $PREFDIR/inactive-tray-border
		echo "#A9A9A9" > $PREFDIR/active-primary-traybutton-bg
		echo "#A9A9A9" > $PREFDIR/active-secondary-traybutton-bg
		echo "#DCDAD5" > $PREFDIR/inactive-primary-traybutton-bg
		echo "#DCDAD5" > $PREFDIR/inactive-secondary-traybutton-bg
		echo "#000000" > $PREFDIR/active-traybutton-fg
		echo "#000000" > $PREFDIR/inactive-traybutton-fg
		echo "#000000" > $PREFDIR/inactive-traybutton-border
		echo "#A9A9A9" > $PREFDIR/active-primary-tasklist-bg
		echo "#A9A9A9" > $PREFDIR/active-secondary-tasklist-bg
		echo "#C2C2C2" > $PREFDIR/inactive-primary-tasklist-bg
		echo "#C2C2C2" > $PREFDIR/inactive-secondary-tasklist-bg
		echo "#000000" > $PREFDIR/active-tasklist-fg
		echo "#000000" > $PREFDIR/inactive-tasklist-fg
		echo "#000000" > $PREFDIR/inactive-tasklist-border
		echo "#3A4956" > $PREFDIR/active-primary-pager-bg
		echo "#888888" > $PREFDIR/inactive-primary-pager-bg
		echo "#8899AA" > $PREFDIR/active-pager-fg
		echo "#DCDAD5" > $PREFDIR/inactive-pager-fg
		echo "#000000" > $PREFDIR/inactive-pager-border
		echo "#000000" > $PREFDIR/popup-fg
		echo "#000000" > $PREFDIR/popup-border
		echo "#FFFAD2" > $PREFDIR/popup-bg
		echo "#000000" > $PREFDIR/clock-fg
		echo "#DCDAD5" > $PREFDIR/primary-clock-bg
		echo "#DCDAD5" > $PREFDIR/secondary-clock-bg
	elif [ "$jwmtheme_template" = "Dark" ]; then # stardust-dark
		echo "Sans" > $PREFDIR/theme-font-name
		echo "10" > $PREFDIR/theme-font-size
		echo "normal" > $PREFDIR/theme-font-attributes
		echo "22" > $PREFDIR/window-titlebar-height
		echo "4" > $PREFDIR/window-border-width
		echo "3" > $PREFDIR/window-corner-radius
		echo "#222222" > $PREFDIR/active-primary-window-bg
		echo "#757575" > $PREFDIR/active-secondary-window-bg
		echo "#999999" > $PREFDIR/inactive-primary-window-bg
		echo "#757575" > $PREFDIR/inactive-secondary-window-bg
		echo "#EEEEEE" > $PREFDIR/active-window-fg
		echo "#BBBBBB" > $PREFDIR/inactive-window-fg
		echo "#444444" > $PREFDIR/active-window-border
		echo "#777777" > $PREFDIR/inactive-window-border
		echo "#DDBB98" > $PREFDIR/active-primary-menu-bg
		echo "#C47625" > $PREFDIR/active-secondary-menu-bg
		echo "#444444" > $PREFDIR/inactive-primary-menu-bg
		echo "#000000" > $PREFDIR/active-menu-fg
		echo "#BBBBBB" > $PREFDIR/inactive-menu-fg
		echo "#222222" > $PREFDIR/inactive-menu-border
		echo "#DDBB98" > $PREFDIR/active-primary-tray-bg
		echo "#9B5D1C" > $PREFDIR/active-secondary-tray-bg
		echo "#888888" > $PREFDIR/inactive-primary-tray-bg
		echo "#333333" > $PREFDIR/inactive-secondary-tray-bg
		echo "#222222" > $PREFDIR/active-tray-fg
		echo "#BBBBBB" > $PREFDIR/inactive-tray-fg
		echo "#444444" > $PREFDIR/inactive-tray-border
		echo "#DDBB98" > $PREFDIR/active-primary-traybutton-bg
		echo "#9B5D1C" > $PREFDIR/active-secondary-traybutton-bg
		echo "#888888" > $PREFDIR/inactive-primary-traybutton-bg
		echo "#333333" > $PREFDIR/inactive-secondary-traybutton-bg
		echo "#222222" > $PREFDIR/active-traybutton-fg
		echo "#BBBBBB" > $PREFDIR/inactive-traybutton-fg
		echo "#444444" > $PREFDIR/inactive-traybutton-border
		echo "#DDBB98" > $PREFDIR/active-primary-tasklist-bg
		echo "#9B5D1C" > $PREFDIR/active-secondary-tasklist-bg
		echo "#888888" > $PREFDIR/inactive-primary-tasklist-bg
		echo "#333333" > $PREFDIR/inactive-secondary-tasklist-bg
		echo "#222222" > $PREFDIR/active-tasklist-fg
		echo "#BBBBBB" > $PREFDIR/inactive-tasklist-fg
		echo "#444444" > $PREFDIR/inactive-tasklist-border
		echo "#734822" > $PREFDIR/active-primary-pager-bg
		echo "#333333" > $PREFDIR/inactive-primary-pager-bg
		echo "#E1A053" > $PREFDIR/active-pager-fg
		echo "#888888" > $PREFDIR/inactive-pager-fg
		echo "#000000" > $PREFDIR/inactive-pager-border
		echo "#222222" > $PREFDIR/popup-fg
		echo "#222222" > $PREFDIR/popup-border
		echo "#CEA87E" > $PREFDIR/popup-bg
		echo "#BBBBBB" > $PREFDIR/clock-fg
		echo "#888888" > $PREFDIR/primary-clock-bg
		echo "#333333" > $PREFDIR/secondary-clock-bg
	else # stardust-bright
		echo "Sans" > $PREFDIR/theme-font-name
		echo "10" > $PREFDIR/theme-font-size
		echo "normal" > $PREFDIR/theme-font-attributes
		echo "22" > $PREFDIR/window-titlebar-height
		echo "4" > $PREFDIR/window-border-width
		echo "3" > $PREFDIR/window-corner-radius
		echo "#888888" > $PREFDIR/active-primary-window-bg
		echo "#D6DBDF" > $PREFDIR/active-secondary-window-bg
		echo "#CCCCCC" > $PREFDIR/inactive-primary-window-bg
		echo "#D6DBDF" > $PREFDIR/inactive-secondary-window-bg
		echo "#222222" > $PREFDIR/active-window-fg
		echo "#999999" > $PREFDIR/inactive-window-fg
		echo "#777777" > $PREFDIR/active-window-border
		echo "#AAAAAA" > $PREFDIR/inactive-window-border
		echo "#CDE5F2" > $PREFDIR/active-primary-menu-bg
		echo "#5395AF" > $PREFDIR/active-secondary-menu-bg
		echo "#DCDAD5" > $PREFDIR/inactive-primary-menu-bg
		echo "#000000" > $PREFDIR/active-menu-fg
		echo "#000000" > $PREFDIR/inactive-menu-fg
		echo "#999999" > $PREFDIR/inactive-menu-border
		echo "#FFFFFF" > $PREFDIR/active-primary-tray-bg
		echo "#578090" > $PREFDIR/active-secondary-tray-bg
		echo "#FFFFFF" > $PREFDIR/inactive-primary-tray-bg
		echo "#A4A4A4" > $PREFDIR/inactive-secondary-tray-bg
		echo "#000000" > $PREFDIR/active-tray-fg
		echo "#333333" > $PREFDIR/inactive-tray-fg
		echo "#FFFFFF" > $PREFDIR/inactive-tray-border
		echo "#FFFFFF" > $PREFDIR/active-primary-traybutton-bg
		echo "#578090" > $PREFDIR/active-secondary-traybutton-bg
		echo "#FFFFFF" > $PREFDIR/inactive-primary-traybutton-bg
		echo "#A4A4A4" > $PREFDIR/inactive-secondary-traybutton-bg
		echo "#000000" > $PREFDIR/active-traybutton-fg
		echo "#333333" > $PREFDIR/inactive-traybutton-fg
		echo "#FFFFFF" > $PREFDIR/inactive-traybutton-border
		echo "#FFFFFF" > $PREFDIR/active-primary-tasklist-bg
		echo "#578090" > $PREFDIR/active-secondary-tasklist-bg
		echo "#FFFFFF" > $PREFDIR/inactive-primary-tasklist-bg
		echo "#A4A4A4" > $PREFDIR/inactive-secondary-tasklist-bg
		echo "#000000" > $PREFDIR/active-tasklist-fg
		echo "#333333" > $PREFDIR/inactive-tasklist-fg
		echo "#FFFFFF" > $PREFDIR/inactive-tasklist-border
		echo "#3A4956" > $PREFDIR/active-primary-pager-bg
		echo "#888888" > $PREFDIR/inactive-primary-pager-bg
		echo "#8899AA" > $PREFDIR/active-pager-fg
		echo "#DCDAD5" > $PREFDIR/inactive-pager-fg
		echo "#000000" > $PREFDIR/inactive-pager-border
		echo "#000000" > $PREFDIR/popup-fg
		echo "#000000" > $PREFDIR/popup-border
		echo "#91AABF" > $PREFDIR/popup-bg
		echo "#333333" > $PREFDIR/clock-fg
		echo "#FFFFFF" > $PREFDIR/primary-clock-bg
		echo "#A4A4A4" > $PREFDIR/secondary-clock-bg
	fi
fi

NEWTHEME=$(cat /tmp/newtheme | awk -F'/' '{print $NF}' 2>/dev/null)
[ "$NEWTHEME" ] && echo "$NEWTHEME" > /tmp/newtheme || NEWTHEME=""

########################################################################
#                                                                      #
# CURRENT SETTINGS                                                     #
#                                                                      #
########################################################################

## Font parameters ##

# theme font name
theme_font_name=$(cat $PREFDIR/theme-font-name 2>/dev/null)
[ ! "$theme_font_name" ] && theme_font_name="Sans" && echo "$theme_font_name" > $PREFDIR/theme-font-name
theme_font_name_items=$(echo -e "Sans\n`fc-list : family | cut -d',' -f1 | sort -u`" | awk '{print "<item>"$1" "$2" "$3" "$4"</item>"}' | sed -e 's/ //g;s/\\//g')
[ ! "$theme_font_name_items" ] && theme_font_name_items="<item>Sans</item>"

# theme font size
theme_font_size=$(cat $PREFDIR/theme-font-size 2>/dev/null)
[ ! "$theme_font_size" ] && theme_font_size="10" && echo "$theme_font_size" > $PREFDIR/theme-font-size

# theme font attributes
theme_font_attributes=$(cat $PREFDIR/theme-font-attributes 2>/dev/null)
[ ! "$theme_font_attributes" ] && theme_font_attributes="normal" && echo "$theme_font_attributes" > $PREFDIR/theme-font-attributes

## Window parameters ##

# active background colors
active_primary_window_bg=$(cat $PREFDIR/active-primary-window-bg 2>/dev/null)
[ ! "$active_primary_window_bg" ] && active_primary_window_bg="#888888" && echo "$active_primary_window_bg" > $PREFDIR/active-primary-window-bg
active_secondary_window_bg=$(cat $PREFDIR/active-secondary-window-bg 2>/dev/null)
[ ! "$active_secondary_window_bg" ] && active_secondary_window_bg="#D6DBDF" && echo "$active_secondary_window_bg" > $PREFDIR/active-secondary-window-bg

# inactive background colors
inactive_primary_window_bg=$(cat $PREFDIR/inactive-primary-window-bg 2>/dev/null)
[ ! "$inactive_primary_window_bg" ] && inactive_primary_window_bg="#CCCCCC" && echo "$inactive_primary_window_bg" > $PREFDIR/inactive-primary-window-bg
inactive_secondary_window_bg=$(cat $PREFDIR/inactive-secondary-window-bg 2>/dev/null)
[ ! "$inactive_secondary_window_bg" ] && inactive_secondary_window_bg="#D6DBDF" && echo "$inactive_secondary_window_bg" > $PREFDIR/inactive-secondary-window-bg

# active foreground color
active_window_fg=$(cat $PREFDIR/active-window-fg 2>/dev/null)
[ ! "$active_window_fg" ] && active_window_fg="#222222" && echo "$active_window_fg" > $PREFDIR/active-window-fg

# inactive foreground color
inactive_window_fg=$(cat $PREFDIR/inactive-window-fg 2>/dev/null)
[ ! "$inactive_window_fg" ] && inactive_window_fg="#999999" && echo "$inactive_window_fg" > $PREFDIR/inactive-window-fg

# active window border color
active_window_border=$(cat $PREFDIR/active-window-border 2>/dev/null)
[ ! "$active_window_border" ] && active_window_border="#777777" && echo "$active_window_border" > $PREFDIR/active-window-border

# inactive window border color
inactive_window_border=$(cat $PREFDIR/inactive-window-border 2>/dev/null)
[ ! "$inactive_window_border" ] && inactive_window_border="#aaaaaa" && echo "$inactive_window_border" > $PREFDIR/inactive-window-border

# window titlebar height
window_titlebar_height=$(cat $PREFDIR/window-titlebar-height 2>/dev/null)
[ ! "$window_titlebar_height" ] && window_titlebar_height="22" && echo "$window_titlebar_height" > $PREFDIR/window-titlebar-height

# window border width
window_border_width=$(cat $PREFDIR/window-border-width 2>/dev/null)
[ ! "$window_border_width" ] && window_border_width="4" && echo "$window_border_width" > $PREFDIR/window-border-width

# window corner radius
window_corner_radius=$(cat $PREFDIR/window-corner-radius 2>/dev/null)
[ ! "$window_corner_radius" ] && window_corner_radius="3" && echo "$window_corner_radius" > $PREFDIR/window-corner-radius

## Menu parameters ##

# active menu background colors
active_primary_menu_bg=$(cat $PREFDIR/active-primary-menu-bg 2>/dev/null)
[ ! "$active_primary_menu_bg" ] && active_primary_menu_bg="#CDE5F2" && echo "$active_primary_menu_bg" > $PREFDIR/active-primary-menu-bg
active_secondary_menu_bg=$(cat $PREFDIR/active-secondary-menu-bg 2>/dev/null)
[ ! "$active_secondary_menu_bg" ] && active_secondary_menu_bg="#5395AF" && echo "$active_secondary_menu_bg" > $PREFDIR/active-secondary-menu-bg

# inactive menu background color
inactive_primary_menu_bg=$(cat $PREFDIR/inactive-primary-menu-bg 2>/dev/null)
[ ! "$inactive_primary_menu_bg" ] && inactive_primary_menu_bg="#DCDAD5" && echo "$inactive_primary_menu_bg" > $PREFDIR/inactive-primary-menu-bg

# active menu foreground color
active_menu_fg=$(cat $PREFDIR/active-menu-fg 2>/dev/null)
[ ! "$active_menu_fg" ] && active_menu_fg="#000000" && echo "$active_menu_fg" > $PREFDIR/active-menu-fg

# inactive menu foreground color
inactive_menu_fg=$(cat $PREFDIR/inactive-menu-fg 2>/dev/null)
[ ! "$inactive_menu_fg" ] && inactive_menu_fg="#000000" && echo "$inactive_menu_fg" > $PREFDIR/inactive-menu-fg

# inactive menu border
inactive_menu_border=$(cat $PREFDIR/inactive-menu-border 2>/dev/null)
[ ! "$inactive_menu_border" ] && inactive_menu_border="#999999" && echo "$inactive_menu_border" > $PREFDIR/inactive-menu-border

## Tray parameters ##

# active background colors
active_primary_tray_bg=$(cat $PREFDIR/active-primary-tray-bg 2>/dev/null)
[ ! "$active_primary_tray_bg" ] && active_primary_tray_bg="#FFFFFF" && echo "$active_primary_tray_bg" > $PREFDIR/active-primary-tray-bg
active_secondary_tray_bg=$(cat $PREFDIR/active-secondary-tray-bg 2>/dev/null)
[ ! "$active_secondary_tray_bg" ] && active_secondary_tray_bg="#578090" && echo "$active_secondary_tray_bg" > $PREFDIR/active-secondary-tray-bg

# inactive background colors
inactive_primary_tray_bg=$(cat $PREFDIR/inactive-primary-tray-bg 2>/dev/null)
[ ! "$inactive_primary_tray_bg" ] && inactive_primary_tray_bg="#FFFFFF" && echo "$inactive_primary_tray_bg" > $PREFDIR/inactive-primary-tray-bg
inactive_secondary_tray_bg=$(cat $PREFDIR/inactive-secondary-tray-bg 2>/dev/null)
[ ! "$inactive_secondary_tray_bg" ] && inactive_secondary_tray_bg="#A4A4A4" && echo "$inactive_secondary_tray_bg" > $PREFDIR/inactive-secondary-tray-bg

# active foreground color
active_tray_fg=$(cat $PREFDIR/active-tray-fg 2>/dev/null)
[ ! "$active_tray_fg" ] && active_tray_fg="#000000" && echo "$active_tray_fg" > $PREFDIR/active-tray-fg

# inactive foreground color
inactive_tray_fg=$(cat $PREFDIR/inactive-tray-fg 2>/dev/null)
[ ! "$inactive_tray_fg" ] && inactive_tray_fg="#333333" && echo "$inactive_tray_fg" > $PREFDIR/inactive-tray-fg

# inactive tray border color
inactive_tray_border=$(cat $PREFDIR/inactive-tray-border 2>/dev/null)
[ ! "$inactive_tray_border" ] && inactive_tray_border="#ffffff" && echo "$inactive_tray_border" > $PREFDIR/inactive-tray-border

## Traybutton parameters ##

# active background colors
active_primary_traybutton_bg=$(cat $PREFDIR/active-primary-traybutton-bg 2>/dev/null)
[ ! "$active_primary_traybutton_bg" ] && active_primary_traybutton_bg="#FFFFFF" && echo "$active_primary_traybutton_bg" > $PREFDIR/active-primary-traybutton-bg
active_secondary_traybutton_bg=$(cat $PREFDIR/active-secondary-traybutton-bg 2>/dev/null)
[ ! "$active_secondary_traybutton_bg" ] && active_secondary_traybutton_bg="#578090" && echo "$active_secondary_traybutton_bg" > $PREFDIR/active-secondary-traybutton-bg

# inactive background colors
inactive_primary_traybutton_bg=$(cat $PREFDIR/inactive-primary-traybutton-bg 2>/dev/null)
[ ! "$inactive_primary_traybutton_bg" ] && inactive_primary_traybutton_bg="#FFFFFF" && echo "$inactive_primary_traybutton_bg" > $PREFDIR/inactive-primary-traybutton-bg
inactive_secondary_traybutton_bg=$(cat $PREFDIR/inactive-secondary-traybutton-bg 2>/dev/null)
[ ! "$inactive_secondary_traybutton_bg" ] && inactive_secondary_traybutton_bg="#A4A4A4" && echo "$inactive_secondary_traybutton_bg" > $PREFDIR/inactive-secondary-traybutton-bg

# active foreground color
active_traybutton_fg=$(cat $PREFDIR/active-traybutton-fg 2>/dev/null)
[ ! "$active_traybutton_fg" ] && active_traybutton_fg="#000000" && echo "$active_traybutton_fg" > $PREFDIR/active-traybutton-fg

# inactive foreground color
inactive_traybutton_fg=$(cat $PREFDIR/inactive-traybutton-fg 2>/dev/null)
[ ! "$inactive_traybutton_fg" ] && inactive_traybutton_fg="#333333" && echo "$inactive_traybutton_fg" > $PREFDIR/inactive-traybutton-fg

# inactive traybutton border color
inactive_traybutton_border=$(cat $PREFDIR/inactive-traybutton-border 2>/dev/null)
[ ! "$inactive_traybutton_border" ] && inactive_traybutton_border="#ffffff" && echo "$inactive_traybutton_border" > $PREFDIR/inactive-traybutton-border

## TaskList parameters ##

# active background colors
active_primary_tasklist_bg=$(cat $PREFDIR/active-primary-tasklist-bg 2>/dev/null)
[ ! "$active_primary_tasklist_bg" ] && active_primary_tasklist_bg="#FFFFFF" && echo "$active_primary_tasklist_bg" > $PREFDIR/active-primary-tasklist-bg
active_secondary_tasklist_bg=$(cat $PREFDIR/active-secondary-tasklist-bg 2>/dev/null)
[ ! "$active_secondary_tasklist_bg" ] && active_secondary_tasklist_bg="#578090" && echo "$active_secondary_tasklist_bg" > $PREFDIR/active-secondary-tasklist-bg

# inactive background colors
inactive_primary_tasklist_bg=$(cat $PREFDIR/inactive-primary-tasklist-bg 2>/dev/null)
[ ! "$inactive_primary_tasklist_bg" ] && inactive_primary_tasklist_bg="#FFFFFF" && echo "$inactive_primary_tasklist_bg" > $PREFDIR/inactive-primary-tasklist-bg
inactive_secondary_tasklist_bg=$(cat $PREFDIR/inactive-secondary-tasklist-bg 2>/dev/null)
[ ! "$inactive_secondary_tasklist_bg" ] && inactive_secondary_tasklist_bg="#A4A4A4" && echo "$inactive_secondary_tasklist_bg" > $PREFDIR/inactive-secondary-tasklist-bg

# active foreground color
active_tasklist_fg=$(cat $PREFDIR/active-tasklist-fg 2>/dev/null)
[ ! "$active_tasklist_fg" ] && active_tasklist_fg="#000000" && echo "$active_tasklist_fg" > $PREFDIR/active-tasklist-fg

# inactive foreground color
inactive_tasklist_fg=$(cat $PREFDIR/inactive-tasklist-fg 2>/dev/null)
[ ! "$inactive_tasklist_fg" ] && inactive_tasklist_fg="#333333" && echo "$inactive_tasklist_fg" > $PREFDIR/inactive-tasklist-fg

# inactive tasklist border color
inactive_tasklist_border=$(cat $PREFDIR/inactive-tasklist-border 2>/dev/null)
[ ! "$inactive_tasklist_border" ] && inactive_tasklist_border="#ffffff" && echo "$inactive_tasklist_border" > $PREFDIR/inactive-tasklist-border

## Pager parameters ##

# active background color
active_primary_pager_bg=$(cat $PREFDIR/active-primary-pager-bg 2>/dev/null)
[ ! "$active_primary_pager_bg" ] && active_primary_pager_bg="#3A4956" && echo "$active_primary_pager_bg" > $PREFDIR/active-primary-pager-bg

# inactive background color
inactive_primary_pager_bg=$(cat $PREFDIR/inactive-primary-pager-bg 2>/dev/null)
[ ! "$inactive_primary_pager_bg" ] && inactive_primary_pager_bg="#888888" && echo "$inactive_primary_pager_bg" > $PREFDIR/inactive-primary-pager-bg

# active foreground color
active_pager_fg=$(cat $PREFDIR/active-pager-fg 2>/dev/null)
[ ! "$active_pager_fg" ] && active_pager_fg="#8899AA" && echo "$active_pager_fg" > $PREFDIR/active-pager-fg

# inactive foreground color
inactive_pager_fg=$(cat $PREFDIR/inactive-pager-fg 2>/dev/null)
[ ! "$inactive_pager_fg" ] && inactive_pager_fg="#DCDAD5" && echo "$inactive_pager_fg" > $PREFDIR/inactive-pager-fg

# inactive pager border color
inactive_pager_border=$(cat $PREFDIR/inactive-pager-border 2>/dev/null)
[ ! "$inactive_pager_border" ] && inactive_pager_border="#000000" && echo "$inactive_pager_border" > $PREFDIR/inactive-pager-border

## Popup parameters ##

# popup foreground
popup_fg=$(cat $PREFDIR/popup-fg 2>/dev/null)
[ ! "$popup_fg" ] && popup_fg="#000000" && echo "$popup_fg" > $PREFDIR/popup-fg

# popup background
popup_bg=$(cat $PREFDIR/popup-bg 2>/dev/null)
[ ! "$popup_bg" ] && popup_bg="#91AABF" && echo "$popup_bg" > $PREFDIR/popup-bg

# popup border
popup_border=$(cat $PREFDIR/popup-border 2>/dev/null)
[ ! "$popup_border" ] && popup_border="#000000" && echo "$popup_border" > $PREFDIR/popup-border

## Clock parameters ##

# clock foreground
clock_fg=$(cat $PREFDIR/clock-fg 2>/dev/null)
[ ! "$clock_fg" ] && clock_fg="#333333" && echo "$clock_fg" > $PREFDIR/clock-fg

# clock background
primary_clock_bg=$(cat $PREFDIR/primary-clock-bg 2>/dev/null)
[ ! "$primary_clock_bg" ] && primary_clock_bg="#FFFFFF" && echo "$primary_clock_bg" > $PREFDIR/primary-clock-bg
secondary_clock_bg=$(cat $PREFDIR/secondary-clock-bg 2>/dev/null)
[ ! "$secondary_clock_bg" ] && secondary_clock_bg="#A4A4A4" && echo "$secondary_clock_bg" > $PREFDIR/secondary-clock-bg

########################################################################
#                                                                      #
# STYLE DIALOGS                                                        #
#                                                                      #
########################################################################

WINDOW_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true" space-expand="false" space-fill="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Window')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Geometry')"'"</label></text>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<text><label>'$(gettext 'Title Bar Height')'</label></text>
			<spinbutton height-request="30" width-request="50" range-min="1" range-max="64" range-step="1" range-value="22" tooltip-text=" '$(gettext 'Range:1-64px  Default:22px')' ">
				<variable>window_titlebar_height</variable>
				<input>cat '$PREFDIR'/window-titlebar-height</input>
			</spinbutton>
		</vbox>
		<vbox space-expand="true" space-fill="false">
			<text><label>'$(gettext 'Border')'</label></text>
			<spinbutton height-request="30" width-request="50" range-min="1" range-max="64" range-step="1" range-value="4" tooltip-text=" '$(gettext 'Range:1-64px  Default:4px')' ">
				<variable>window_border_width</variable>
				<input>cat '$PREFDIR'/window-border-width</input>
			</spinbutton>
		</vbox>
		<vbox space-expand="true" space-fill="false">
			<text><label>'$(gettext 'Corner')'</label></text>
			<spinbutton height-request="30" width-request="50" range-min="0" range-max="5" range-step="1" range-value="3" tooltip-text=" '$(gettext 'Range:0-5px  Default:3px 
 Note: 0 = square corners')' ">
				<variable>window_corner_radius</variable>
				<input>cat '$PREFDIR'/window-corner-radius</input>
			</spinbutton>
		</vbox>
		</hbox>

		<pixmap><input file>'$ICONDIR'/blank1.png</input></pixmap>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text><label>" "</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<text xalign="2"><label>"'"$(gettext 'Background')"'"</label></text>
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active window background-1" tooltip-text=" '$(gettext 'Active window background-1')' ">
				<input file>'$PREFDIR'/active-primary-window-bg</input>
				<variable>active_primary_window_bg</variable>
				<action>echo $active_primary_window_bg > '$PREFDIR'/active-primary-window-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active window background-2" tooltip-text=" '$(gettext 'Active window background-2')' ">
				<input file>'$PREFDIR'/active-secondary-window-bg</input>
				<variable>active_secondary_window_bg</variable>
				<action>echo $active_secondary_window_bg > '$PREFDIR'/active-secondary-window-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<text xalign="2"><label>"'"$(gettext 'Foreground')"'"</label></text>
		<hbox space-expand="false" space-fill="true">
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active window foreground" tooltip-text=" '$(gettext 'Active window foreground')' ">
				<input file>'$PREFDIR'/active-window-fg</input>
				<variable>active_window_fg</variable>
				<action>echo $active_window_fg > '$PREFDIR'/active-window-fg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<text xalign="2"><label>"'"$(gettext 'Border')"'"</label></text>
		<hbox space-expand="false" space-fill="true">
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active window border" tooltip-text=" '$(gettext 'Active window border')' ">
				<input file>'$PREFDIR'/active-window-border</input>
				<variable>active_window_border</variable>
				<action>echo $active_window_border > '$PREFDIR'/active-window-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive window background-1" tooltip-text=" '$(gettext 'Inactive window background-1')' ">
				<input file>'$PREFDIR'/inactive-primary-window-bg</input>
				<variable>inactive_primary_window_bg</variable>
				<action>echo $inactive_primary_window_bg > '$PREFDIR'/inactive-primary-window-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive window background-2" tooltip-text=" '$(gettext 'Inactive window background-2')' ">
				<input file>'$PREFDIR'/inactive-secondary-window-bg</input>
				<variable>inactive_secondary_window_bg</variable>
				<action>echo $inactive_secondary_window_bg > '$PREFDIR'/inactive-secondary-window-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive window foreground" tooltip-text=" '$(gettext 'Inactive window foreground')' ">
				<input file>'$PREFDIR'/inactive-window-fg</input>
				<variable>inactive_window_fg</variable>
				<action>echo $inactive_window_fg > '$PREFDIR'/inactive-window-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive window border" tooltip-text=" '$(gettext 'Inactive window border')' ">
				<input file>'$PREFDIR'/inactive-window-border</input>
				<variable>inactive_window_border</variable>
				<action>echo $inactive_window_border > '$PREFDIR'/inactive-window-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

MENU_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Menu')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active menu background-1" tooltip-text=" '$(gettext 'Active menu background-1')' ">
				<input file>'$PREFDIR'/active-primary-menu-bg</input>
				<variable>active_primary_menu_bg</variable>
				<action>echo $active_primary_menu_bg > '$PREFDIR'/active-primary-menu-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active menu background-2" tooltip-text=" '$(gettext 'Active menu background-2')' ">
				<input file>'$PREFDIR'/active-secondary-menu-bg</input>
				<variable>active_secondary_menu_bg</variable>
				<action>echo $active_secondary_menu_bg > '$PREFDIR'/active-secondary-menu-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active menu foreground" tooltip-text=" '$(gettext 'Active menu foreground')' ">
				<input file>'$PREFDIR'/active-menu-fg</input>
				<variable>active_menu_fg</variable>
				<action>echo $active_menu_fg > '$PREFDIR'/active-menu-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive menu background" tooltip-text=" '$(gettext 'Inactive menu background')' ">
				<input file>'$PREFDIR'/inactive-primary-menu-bg</input>
				<variable>inactive_primary_menu_bg</variable>
				<action>echo $inactive_primary_menu_bg > '$PREFDIR'/inactive-primary-menu-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive menu foreground" tooltip-text=" '$(gettext 'Inactive menu foreground')' ">
				<input file>'$PREFDIR'/inactive-menu-fg</input>
				<variable>inactive_menu_fg</variable>
				<action>echo $inactive_menu_fg > '$PREFDIR'/inactive-menu-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Menu border" tooltip-text=" '$(gettext 'Menu border')' ">
				<input file>'$PREFDIR'/inactive-menu-border</input>
				<variable>inactive_menu_border</variable>
				<action>echo $inactive_menu_border > '$PREFDIR'/inactive-menu-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

TRAY_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Tray')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tray background-1" tooltip-text=" '$(gettext 'Active tray background-1')' ">
				<input file>'$PREFDIR'/active-primary-tray-bg</input>
				<variable>active_primary_tray_bg</variable>
				<action>echo $active_primary_tray_bg > '$PREFDIR'/active-primary-tray-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tray background-2" tooltip-text=" '$(gettext 'Active tray background-2')' ">
				<input file>'$PREFDIR'/active-secondary-tray-bg</input>
				<variable>active_secondary_tray_bg</variable>
				<action>echo $active_secondary_tray_bg > '$PREFDIR'/active-secondary-tray-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox space-expand="false" space-fill="true">
		<vbox width-request="105" space-expand="true" space-fill="false">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tray foreground" tooltip-text=" '$(gettext 'Active tray foreground')' ">
				<input file>'$PREFDIR'/active-tray-fg</input>
				<variable>active_tray_fg</variable>
				<action>echo $active_tray_fg > '$PREFDIR'/active-tray-fg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox space-expand="false" space-fill="true">
		<vbox width-request="105" space-expand="true" space-fill="false">
		<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tray background-1" tooltip-text=" '$(gettext 'Inactive tray background-1')' ">
				<input file>'$PREFDIR'/inactive-primary-tray-bg</input>
				<variable>inactive_primary_tray_bg</variable>
				<action>echo $inactive_primary_tray_bg > '$PREFDIR'/inactive-primary-tray-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tray background-2" tooltip-text=" '$(gettext 'Inactive tray background-2')' ">
				<input file>'$PREFDIR'/inactive-secondary-tray-bg</input>
				<variable>inactive_secondary_tray_bg</variable>
				<action>echo $inactive_secondary_tray_bg > '$PREFDIR'/inactive-secondary-tray-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tray foreground" tooltip-text=" '$(gettext 'Inactive tray foreground')' ">
				<input file>'$PREFDIR'/inactive-tray-fg</input>
				<variable>inactive_tray_fg</variable>
				<action>echo $inactive_tray_fg > '$PREFDIR'/inactive-tray-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Tray border" tooltip-text=" '$(gettext 'Tray border')' ">
				<input file>'$PREFDIR'/inactive-tray-border</input>
				<variable>inactive_tray_border</variable>
				<action>echo $inactive_tray_border > '$PREFDIR'/inactive-tray-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

TRAYBUTTON_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Tray Button')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active traybutton background-1" tooltip-text=" '$(gettext 'Active traybutton background-1')' ">
				<input file>'$PREFDIR'/active-primary-traybutton-bg</input>
				<variable>active_primary_traybutton_bg</variable>
				<action>echo $active_primary_traybutton_bg > '$PREFDIR'/active-primary-traybutton-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active traybutton background-2" tooltip-text=" '$(gettext 'Active traybutton background-2')' ">
				<input file>'$PREFDIR'/active-secondary-traybutton-bg</input>
				<variable>active_secondary_traybutton_bg</variable>
				<action>echo $active_secondary_traybutton_bg > '$PREFDIR'/active-secondary-traybutton-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active traybutton foreground" tooltip-text=" '$(gettext 'Active traybutton foreground')' ">
				<input file>'$PREFDIR'/active-traybutton-fg</input>
				<variable>active_traybutton_fg</variable>
				<action>echo $active_traybutton_fg > '$PREFDIR'/active-traybutton-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive traybutton background-1" tooltip-text=" '$(gettext 'Inactive traybutton background-1')' ">
				<input file>'$PREFDIR'/inactive-primary-traybutton-bg</input>
				<variable>inactive_primary_traybutton_bg</variable>
				<action>echo $inactive_primary_traybutton_bg > '$PREFDIR'/inactive-primary-traybutton-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive traybutton background-2" tooltip-text=" '$(gettext 'Inactive traybutton background-2')' ">
				<input file>'$PREFDIR'/inactive-secondary-traybutton-bg</input>
				<variable>inactive_secondary_traybutton_bg</variable>
				<action>echo $inactive_secondary_traybutton_bg > '$PREFDIR'/inactive-secondary-traybutton-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive traybutton foreground" tooltip-text=" '$(gettext 'Inactive traybutton foreground')' ">
				<input file>'$PREFDIR'/inactive-traybutton-fg</input>
				<variable>inactive_traybutton_fg</variable>
				<action>echo $inactive_traybutton_fg > '$PREFDIR'/inactive-traybutton-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Traybutton border" tooltip-text=" '$(gettext 'Traybutton border')' ">
				<input file>'$PREFDIR'/inactive-traybutton-border</input>
				<variable>inactive_traybutton_border</variable>
				<action>echo $inactive_traybutton_border > '$PREFDIR'/inactive-traybutton-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

TASKLIST_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Task List')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tasklist background-1" tooltip-text=" '$(gettext 'Active tasklist background-1')' ">
				<input file>'$PREFDIR'/active-primary-tasklist-bg</input>
				<variable>active_primary_tasklist_bg</variable>
				<action>echo $active_primary_tasklist_bg > '$PREFDIR'/active-primary-tasklist-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tasklist background-2" tooltip-text=" '$(gettext 'Active tasklist background-2')' ">
				<input file>'$PREFDIR'/active-secondary-tasklist-bg</input>
				<variable>active_secondary_tasklist_bg</variable>
				<action>echo $active_secondary_tasklist_bg > '$PREFDIR'/active-secondary-tasklist-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active tasklist foreground" tooltip-text=" '$(gettext 'Active tasklist foreground')' ">
				<input file>'$PREFDIR'/active-tasklist-fg</input>
				<variable>active_tasklist_fg</variable>
				<action>echo $active_tasklist_fg > '$PREFDIR'/active-tasklist-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tasklist background-1" tooltip-text=" '$(gettext 'Inactive tasklist background-1')' ">
				<input file>'$PREFDIR'/inactive-primary-tasklist-bg</input>
				<variable>inactive_primary_tasklist_bg</variable>
				<action>echo $inactive_primary_tasklist_bg > '$PREFDIR'/inactive-primary-tasklist-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tasklist background-2" tooltip-text=" '$(gettext 'Inactive tasklist background-2')' ">
				<input file>'$PREFDIR'/inactive-secondary-tasklist-bg</input>
				<variable>inactive_secondary_tasklist_bg</variable>
				<action>echo $inactive_secondary_tasklist_bg > '$PREFDIR'/inactive-secondary-tasklist-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive tasklist foreground" tooltip-text=" '$(gettext 'Inactive tasklist foreground')' ">
				<input file>'$PREFDIR'/inactive-tasklist-fg</input>
				<variable>inactive_tasklist_fg</variable>
				<action>echo $inactive_tasklist_fg > '$PREFDIR'/inactive-tasklist-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Tasklist border" tooltip-text=" '$(gettext 'Tasklist border')' ">
				<input file>'$PREFDIR'/inactive-tasklist-border</input>
				<variable>inactive_tasklist_border</variable>
				<action>echo $inactive_tasklist_border > '$PREFDIR'/inactive-tasklist-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

PAGER_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Pager')'</span></b>"</label></text>
			<text xalign="0"><label>"  '"$(gettext 'Active')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
		<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active pager background" tooltip-text=" '$(gettext 'Active pager background')' ">
				<input file>'$PREFDIR'/active-primary-pager-bg</input>
				<variable>active_primary_pager_bg</variable>
				<action>echo $active_primary_pager_bg > '$PREFDIR'/active-primary-pager-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Active pager foreground" tooltip-text=" '$(gettext 'Active pager foreground')' ">
				<input file>'$PREFDIR'/active-pager-fg</input>
				<variable>active_pager_fg</variable>
				<action>echo $active_pager_fg > '$PREFDIR'/active-pager-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<text xalign="2"><label>" "</label></text>
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>

		<hbox homogeneous="true" space-expand="true" space-fill="false">
		<vbox homogeneous="true">
			<text xalign="0"><label>"  '"$(gettext 'Inactive')"'"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive pager background" tooltip-text=" '$(gettext 'Inactive pager background')' ">
				<input file>'$PREFDIR'/inactive-primary-pager-bg</input>
				<variable>inactive_primary_pager_bg</variable>
				<action>echo $inactive_primary_pager_bg > '$PREFDIR'/inactive-primary-pager-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Inactive pager foreground" tooltip-text=" '$(gettext 'Inactive pager foreground')' ">
				<input file>'$PREFDIR'/inactive-pager-fg</input>
				<variable>inactive_pager_fg</variable>
				<action>echo $inactive_pager_fg > '$PREFDIR'/inactive-pager-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Pager border" tooltip-text=" '$(gettext 'Pager border')' ">
				<input file>'$PREFDIR'/inactive-pager-border</input>
				<variable>inactive_pager_border</variable>
				<action>echo $inactive_pager_border > '$PREFDIR'/inactive-pager-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

POPUP_STYLE='<vbox space-expand="false" space-fill="true">
		<text xalign="0"><label>" "</label></text>
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Popup')'</span></b>"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Popup background" tooltip-text=" '$(gettext 'Popup background')' ">
				<input file>'$PREFDIR'/popup-bg</input>
				<variable>popup_bg</variable>
				<action>echo $popup_bg > '$PREFDIR'/popup-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Popup foreground" tooltip-text=" '$(gettext 'Popup foreground')' ">
				<input file>'$PREFDIR'/popup-fg</input>
				<variable>popup_fg</variable>
				<action>echo $popup_fg > '$PREFDIR'/popup-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Popup border" tooltip-text=" '$(gettext 'Popup border')' ">
				<input file>'$PREFDIR'/popup-border</input>
				<variable>popup_border</variable>
				<action>echo $popup_border > '$PREFDIR'/popup-border</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

CLOCK_STYLE='<vbox space-expand="false" space-fill="true">
		<hbox homogeneous="true" space-expand="true" space-fill="true">
		<vbox homogeneous="true">
			<text xalign="0" use-markup="true"><label>"<b><span size='"'medium'"'>'$(gettext 'Clock')'</span></b>"</label></text>
		</vbox>
		<vbox space-expand="false" space-fill="true">
		<hbox width-request="105" space-expand="false" space-fill="true">
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Clock background-1" tooltip-text=" '$(gettext 'Clock background-1')' ">
				<input file>'$PREFDIR'/primary-clock-bg</input>
				<variable>primary_clock_bg</variable>
				<action>echo $primary_clock_bg > '$PREFDIR'/primary-clock-bg</action>
			</colorbutton>
		</vbox>
		<vbox space-expand="true" space-fill="true">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Clock background-2" tooltip-text=" '$(gettext 'Clock background-2')' ">
				<input file>'$PREFDIR'/secondary-clock-bg</input>
				<variable>secondary_clock_bg</variable>
				<action>echo $secondary_clock_bg > '$PREFDIR'/secondary-clock-bg</action>
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton height-request="30" width-request="50" space-expand="true" space-fill="true" title="Clock foreground" tooltip-text=" '$(gettext 'Clock foreground')' ">
				<input file>'$PREFDIR'/clock-fg</input>
				<variable>clock_fg</variable>
				<action>echo $clock_fg > '$PREFDIR'/clock-fg</action>
			</colorbutton>
		</vbox>
		<vbox width-request="105" space-expand="true" space-fill="false">
			<colorbutton sensitive="false" height-request="30" width-request="50" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Option not available')' ">
			</colorbutton>
		</vbox>
		</hbox>
		</vbox>'

########################################################################
#                                                                      #
# HELP DIALOG                                                          #
#                                                                      #
########################################################################

gettext "<b><span size='"'x-large'"'>JWM Theme Builder</span></b>

<b>Purpose</b>
The JWM theme defines all colors for the desktop menu, tray and window borders. Although pre-buillt themes are easily available for the JWM desktop, the Theme Builder provides intuitive options to create unliimited new themes with your choice of colors. There are additional options to adjust the window font, border width, corner roundness and title bar height. Generated themes are compatible with the XML format of modern JWM >= 2.3.6.

<b>Colors</b>
The Theme Builder color buttons define the specific coloration of the selected JWM style. For example, the background styles of the menu, tray and window borders are represented by two complementary buttons for the active color and two more for the inactive color. This arrangement supports your choice of flat or gradient colors for each background style.

If you prefer a flat-color style, simply select the identical color for the two complementary background buttons. Otherwise, choose a different color for each button to provide a gradient effect. If a specific color button is disabled by default, this may indicate the selected JWM style is not themable or the style may be limited to one color only with no second-color gradient option.

A convenient color tool button provides quick access to a simple color picker which is particularly useful for the GTK3 desktop environment. 

<b>Edit</b>
GUI buttons are available to access JWM style templates or you can explore the Edit options to select and edit existing themes.

To modify a theme template, select the preferred Base, Light or Dark style and personalize the font and color options, then provide a new theme name.

To edit an existing theme, use the Theme Selector button or simply drag-and-drop a theme from any source directory to the Builder GUI, then click the Edit button to open the theme for modification.

<b>Save</b>
When editing is finished, enter the preferred name for the amended theme (no path required) and click the Save button to archive your creation in the default JWM theme directory. If the selected theme name already exists you will have the option to overwrite or simply cancel and enter a different name.

<b>Preview</b>
Select the Preview button to view and optionally apply the new theme to the current desktop or click the Manage button to view, copy, move or delete files in the default theme directory." > /tmp/themebuilder_help

themebuilder_help()
{
export Help='
<window default-height="450" default-width="650" title="'$(gettext 'Help')'" icon-name="theme_builder" window-position="1" resizable="true">
<vbox height-request="450" width-request="650" space-expand="true" space-fill="true">
	<vbox space-expand="true" space-fill="true">
		<vbox scrollable="true" shadow-type="3" space-expand="true" space-fill="true">
			<vbox space-expand="false" space-fill="false">
				<text xpad="20" ypad="15" use-markup="true"><input file>/tmp/themebuilder_help</input></text>
			</vbox>
		</vbox>
	</vbox>
	<hbox space-expand="false" space-fill="false">
		<button width-request="100">
			<label>'$(gettext 'Close')'</label>
		</button>
	</hbox>
</vbox>
</window>'

$GTKDIALOG -p Help
unset Help
}
export -f themebuilder_help

kill $splashPID 2>/dev/null

########################################################################
#                                                                      #
# MAIN DIALOG                                                          #
#                                                                      #
########################################################################

export THEMEBUILDER='
<window title="'$(gettext "JWM Theme Builder")'" icon-name="theme_builder" resizable="true">
	<vbox>
	'$HEADER'
	 <vbox height-request="450" width-request="650" space-expand="true" space-fill="true">
	  <vbox space-expand="true" space-fill="true">
	   <vbox scrollable="true" margin="10" space-expand="true" space-fill="true">

		<hbox space-expand="true" space-fill="false">
		  <vbox space-expand="true" space-fill="true">
			<vbox space-expand="true" space-fill="true">
				<hbox homogeneous="true" space-expand="true" space-fill="true">
					<comboboxtext wrap-width="1" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Font name')' ">
						<variable>theme_font_name</variable>
						<default>$theme_font_name</default>
						'$theme_font_name_items'
						<action>echo $theme_font_name > '$PREFDIR'/theme-font-name</action>
					</comboboxtext>
				</hbox>
			</vbox>
		  </vbox>
		  <vbox space-expand="true" space-fill="true">
			<vbox space-expand="true" space-fill="true">
				<hbox homogeneous="true" space-expand="true" space-fill="true">
					<comboboxtext wrap-width="1" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Font size')' ">
						<variable>theme_font_size</variable>
						<default>$theme_font_size</default>
						<item>10</item>
						<item>11</item>
						<item>12</item>
						<item>13</item>
						<item>14</item>
						<item>16</item>
						<item>18</item>
						<action>echo $theme_font_size > '$PREFDIR'/theme-font-size</action>
					</comboboxtext>
				</hbox>
			</vbox>
		  </vbox>
		  <vbox space-expand="true" space-fill="true">
			<vbox space-expand="true" space-fill="true">
				<hbox homogeneous="true" space-expand="true" space-fill="true">
					<comboboxtext wrap-width="1" space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Font attributes')' ">
						<variable>theme_font_attributes</variable>
						<default>$theme_font_attributes</default>
						<item>normal</item>
						<item>normal italic</item>
						<item>bold</item>
						<item>bold italic</item>
						<action>echo $theme_font_attributes > '$PREFDIR'/theme-font-attributes</action>
					</comboboxtext>
				</hbox>
			</vbox>
		  </vbox>
		</hbox>

		<pixmap><input file>'$ICONDIR'/blank1.png</input></pixmap>

		<vbox space-expand="true" space-fill="true">
		 '$WINDOW_STYLE'
		 '$MENU_STYLE'
		 '$TRAY_STYLE'
		 '$TRAYBUTTON_STYLE'
		 '$TASKLIST_STYLE'
		 '$PAGER_STYLE'
		 '$POPUP_STYLE'
		 '$CLOCK_STYLE'
		</vbox>

	   </vbox>
	  </vbox>
	 </vbox>

	 <hseparator visible="false" space-expand="false" space-fill="false"></hseparator>

	 <hbox space-expand="false" space-fill="true">
	  <vbox space-expand="false" space-fill="false">
		<button height-request="35" width-request="63" tooltip-text=" '$(gettext 'Color tool')' ">
			<input file>'$ICONDIR'/color-picker.svg</input><height>22</height><width>22</width>
			<action>'$APPDIR'/xcolor &</action>
		</button>
	  </vbox>
	  <vbox space-expand="false" space-fill="false">
		<button height-request="35" width-request="63" tooltip-text=" '$(gettext 'Select new theme template')' ">
			<input file>'$ICONDIR'/update.svg</input><height>22</height><width>22</width>
			<action>newtemplate &</action>
			<action>exit:quit_now</action>
		</button>
	  </vbox>

	  <vbox space-expand="true" space-fill="true">
	  <hbox space-expand="false" space-fill="false">
		<entry space-expand="true" space-fill="true" fs-folder="'$THEMEDIR'" fs-filters="*-jwmrc" fs-title="'$(gettext "Select the JWM theme")'" tooltip-text=" '$(gettext 'Enter new theme name')' " secondary-icon-stock="gtk-clear" secondary-icon-tooltip-text=" '$(gettext 'Clear current name')' "> 
			<variable>NEWTHEME</variable>
			<input>cat /tmp/newtheme 2>/dev/null</input>
			<action>echo "$NEWTHEME" > /tmp/newtheme</action>
			<action signal="secondary-icon-release">clear:NEWTHEME</action>
			<action signal="secondary-icon-release">rm -f /tmp/newtheme 2>/dev/null</action>
		</entry>
		<button height-request="35" width-request="63" tooltip-text=" '$(gettext 'Select existing theme')' ">
			<input file>'$APPDIR'/icons/files.png</input><height>22</height><width>22</width>
			<action>fileselect:NEWTHEME</action>
			<action>echo "$NEWTHEME" > /tmp/newtheme</action>
			<action>refresh:NEWTHEME</action>
		</button>
		<button height-request="35" width-request="63" tooltip-text=" '$(gettext 'Open and edit existing theme')' ">
			<input file>'$ICONDIR'/edit2.svg</input><height>22</height><width>22</width>
			<action>edittheme &</action>
			<action>exit:quit_now</action>
		</button>
	  </hbox>
	  </vbox>
	 </hbox>

	 <hbox space-expand="false" space-fill="false">
		<button width-request="63" space-expand="false" space-fill="false" tooltip-text=" '$(gettext 'Help')' ">
			<input file>'$ICONDIR'/help.svg</input><height>22</height><width>22</width>
			<action>themebuilder_help &</action>
		</button>
		<button space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Manage themes in')' '$THEMEDIR' ">
			<label>'$(gettext 'Manage')'</label>
			<input file>'$ICONDIR'/manage.svg</input><height>22</height><width>22</width>
			<action>defaultfilemanager '$THEMEDIR' &</action>
		</button>
		<button space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Preview and optionally switch to saved theme')' ">
			<label>'$(gettext 'Preview')'</label>
			<input file>'$ICONDIR'/view.svg</input><height>22</height><width>22</width>
			<action>'$APPDIR'/theme_switcher &</action>
		</button>
		<button space-expand="true" space-fill="true" tooltip-text=" '$(gettext 'Save new theme to')' '$THEMEDIR' ">
			<label>'$(gettext 'Save')'</label>
			<input file>'$ICONDIR'/save.svg</input><height>22</height><width>22</width>
			<action>checkname &</action>
		</button>
		<button width-request="63" space-expand="false" space-fill="false" tooltip-text=" '$(gettext 'Quit')' ">
			<input file>'$ICONDIR'/quit.svg</input><height>22</height><width>22</width>
			<action>exit:quit_now</action>
		</button>
	 </hbox>
	</vbox>
  <action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Escape ] && echo true )">exit:EXIT</action>
</window>'

$GTKDIALOG -p THEMEBUILDER --geometry="$GEO" --styles="$STYLE" > /dev/null 2>&1 </dev/null

unset THEMEBUILDER

[ -f /tmp/jwmtheme-template ] && rm -f /tmp/jwmtheme-template

exit 0
