#!/bin/bash
#by Recobayu
#191105 v-0.1 only select favorite color (flatui color)
#191106 v-0.2 wdz color, also menu and tray, tooltip name
#191107 v-0.2.1 use yiq to set foreground to black or white (better than just average the rgb)
#191108 v-0.2.2 recolor. Selected color (active window) is the brightest, the menu is darker, the tray is darkest
#191108 v-0.3 add recent color
#191125 v-0.4 change choosen color when click on favorite or recent color button, exit by Esc key, add pure white and pure black color to favorite
#210725 radky: adjust compatibility with JWMdesk and add new deskop theming options (thank you Recobayu)
#210730 radky: add checkbox option to apply selected color to active window border and active menu background
#210930 radky: adjust brightness and color of active menu background and active tray background
#211031 radky: adjust active background of menu and tray for improved color coordination with GTK themes
#220303 radky: remove duplicative gtk-theme and icon-theme buttons; add options for tray transparency, gradient backgrounds (wallpaper) and selectable colors of menu, tray and background text
#220425 radky: add theming option for title bar buttons; disable folder-color option for non-Rox desktop
#220520 radky: add new style option (Accent) for folder colors
#221018 radky: add new theme builder and title bar manager, plus two new folder color templates (Buntu and Buntu Light)
#230515 radky: add checkbox option to change folder color only and ignore current JWM and background color options

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

[ ! "`pidof jwm`" ] && gtkdialog-splash -close never -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'The JWM window manager is not active !') " && exit 0

JCC=$(busybox ps | grep -Ea -- 'gtkdialog|gtk2dialog' | grep -a -- 'tema_jwm_gui' | awk '{print $1}')

if [ "$JCC" ]; then
	sleep 1
	[ "$JCC" ] && gtkdialog-splash -close never -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'JWMdesk Theme Manager is already active !') " && exit 0
fi

VERSION=1.7
APPDIR=/usr/local/jwmdesk
TMPDIR=/tmp/"`basename $0`"
mkdir -p $TMPDIR
export VERSION APPDIR TMPDIR JCC

[ "`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

# set icon-name
[ ! -f /usr/share/icons/hicolor/48x48/apps/jwm_themes.svg ] && \
ln -sf $APPDIR/icons/jwm_themes.svg /usr/share/icons/hicolor/48x48/apps && gtk-update-icon-cache -f -i /usr/share/icons/hicolor 2>/dev/null

# define desktop interface
ps="`busybox ps`"
echo "$ps" | grep -q -m1 "ROX-Filer -p" && export ROX_PINBOARD="yes"
[ -f $HOME/.config/rox.sourceforge.net/ROX-Filer/Options ] && export ROX_OPTIONS="yes"

########################################################################
#                                                                      #
# GUI PARAMETERS                                                       #
#                                                                      #
########################################################################

# if JWM >= 2.3.6, show theme builder button and use jwmrc-theme2 template
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 # JWM < 2.3.6
	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

if [ "$JWM_VER_OK" = "true" ]; then
	JWMRC="jwmrc-theme2"
	button_themebuilder='
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Legacy JWM theme builder')"' ">
			<input file>'$APPDIR'/icons/theme_builder.svg</input><height>30</height><width>30</width>
			<action>'$APPDIR'/theme_builder &</action>
		</button>'
else
	JWMRC="jwmrc-theme"
	button_themebuilder='
		<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>'
fi
export JWMRC button_themebuilder

# define width of gui and contained widgets
CURRDPI=`grep -a "^Xft\\.dpi:" $HOME/.Xresources 2>/dev/null | tr '\t' ' ' | tr -s ' ' | cut -f 2 -d ' '`
[ ! "$CURRDPI" ] && CURRDPI="110"
if [[ $CURRDPI -ge 130 ]]; then
	gui_width="920" cbox1_width="240" cbox2_width="200" cbox3_width="110" cbox4_width="250" svg_width="90" svg_path="M0 0h90v35H0z"
elif [[ $CURRDPI -ge 120 ]] && [[ $CURRDPI -lt 130 ]]; then
	gui_width="820" cbox1_width="225" cbox2_width="185" cbox3_width="100" cbox4_width="235" svg_width="80" svg_path="M0 0h80v35H0z"
elif [[ $CURRDPI -ge 110 ]] && [[ $CURRDPI -lt 120 ]]; then
	gui_width="776" cbox1_width="215" cbox2_width="175" cbox3_width="95"  cbox4_width="225" svg_width="75" svg_path="M0 0h75v35H0z"
else
	gui_width="740" cbox1_width="205" cbox2_width="165" cbox3_width="90"  cbox4_width="215" svg_width="72" svg_path="M0 0h72v35H0z"
fi
export gui_width cbox1_width cbox2_width cbox3_width cbox4_width svg_width svg_path

# set toggled gui (small or large) to same screen position 
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
GEO=+$((($MX/2)-$((($gui_width+20)/2))))+$((($MY/2)-360))
[ ! "$GEO" ] && GEO=+50+50
export GEO

# define splash dialog
GEO_SPLASH=+$((($MX/2)-$((520/2))))+$((($MY/2)-360))
[ ! "$GEO_SPLASH" ] && GEO_SPLASH=+50+50

#define splash dialog
if [ "`grep -a -- 'Stardust_dark' $HOME/.gtkrc-2.0 2>/dev/null`" ]; then #gold text for Stardust themes
  COLOR=#D7B740
else #light-blue text for common dark themes, otherwise medium blue
  [ "`grep -aEi -- 'black|dark|dusk|night|nox' $HOME/.gtkrc-2.0 2>/dev/null | grep -av -- xfdark`" ] && COLOR=#84aad9 || COLOR=#3272C0
fi
export COLOR

echo 0 > /tmp/thememanager-splash
export THEME_MANAGER_SPLASH='
<window title=" " icon-name="jwm_themes" resizable="false" decorated="true">'"
<vbox width-request=\"500\">
 <pixmap><input file>$APPDIR/icons/jwm_themes.svg</input><height>48</height><width>48</width></pixmap>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>JWM</span><span size='"'x-large'"' color='"$COLOR"'>Desk</span></b>\"</label></text>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Theme Manager</span></b>\"</label></text>"'
 <text><label>Loading...</label></text>
 <progressbar visible="false">
  <input>while [ "$M" != "100" ]; do M=`cat /tmp/thememanager-splash`; echo $M; usleep 500000; done</input>
  <action type="exit">Ready</action>
 </progressbar>
</vbox></window>'
$GTKDIALOG -p THEME_MANAGER_SPLASH --geometry="$GEO_SPLASH" &

# define GTK3 theme settings
if [ -d $HOME/.themes ]; then
 find -L /usr/share/themes -type l -delete 2>/dev/null #remove broken symlinks
 XTRA_GTK_THEMES=$(ls -1A $HOME/.themes/ 2>/dev/null)
 if [ "$XTRA_GTK_THEMES" ]; then
  for t in $XTRA_GTK_THEMES; do
   [ ! -d /usr/share/themes/"$t" ] && ln -snf $HOME/.themes/"$t" /usr/share/themes/
  done
 fi
fi

if [ "`ldd $(which gtkdialog) | grep -Fi 'gtk-3' 2>/dev/null`" ]; then
 [ -f $TMPDIR/gtkrc.css ] && rm -f $TMPDIR/gtkrc.css
 if [ -e "$HOME/.config/gtk-3.0/settings.ini" ] ; then
  THEME=$(grep 'gtk-theme-name' $HOME/.config/gtk-3.0/settings.ini 2>/dev/null | cut -d '=' -f2 | awk '{$1=$1};1')
  CSS=$(find /usr/share/themes/"$THEME"/gtk-3* -maxdepth 2 -name 'gtk.css' -print 2>/dev/null | awk '{print length($0), $0}' | sort -n | sed 's/^[0-9]\+ //' | tail -n1)
 elif [ -e "/etc/gtk-3.0/settings.ini" ] ; then
  THEME=$(grep 'gtk-theme-name' /etc/gtk-3.0/settings.ini 2>/dev/null | cut -d '=' -f2 | awk '{$1=$1};1')
  CSS=$(find /usr/share/themes/"$THEME"/gtk-3* -maxdepth 2 -name 'gtk.css' -print 2>/dev/null | awk '{print length($0), $0}' | sort -n | sed 's/^[0-9]\+ //' | tail -n1)
 fi
 if [ "$THEME" ] && [ -e "$CSS" ] ; then
  DEFINE="@import url(\"$CSS\");"
  echo "$DEFINE" > $TMPDIR/gtkrc.css
 fi
 cat $APPDIR/gtk.css >> $TMPDIR/gtkrc.css
fi

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

# update gtk-icon-theme-name
perbarui_ikon(){
	if [ -e $HOME/.gtkrc-2.0 ]; then
		if [[ $(grep 'gtk-icon-theme-name' $HOME/.gtkrc-2.0) ]]; then
			if [[ ! $(echo $(grep 'gtk-icon-theme-name' $HOME/.gtkrc-2.0 | grep "${folder_style}")) ]]; then
				sed -i "s/^gtk-icon-theme-name.*/gtk-icon-theme-name = \"$folder_style\"/" $HOME/.gtkrc-2.0
			fi
		else
			echo "gtk-icon-theme-name = \"$folder_style\"" >> $HOME/.gtkrc-2.0
		fi
		mkdir -p /etc/gtk-2.0
		cp -f $HOME/.gtkrc-2.0 /etc/gtk-2.0/gtkrc
		chmod 644 /etc/gtk-2.0/gtkrc
	fi
	if [ -e $HOME/.config/gtk-3.0/settings.ini ]; then
		if [[ $(grep 'gtk-icon-theme-name' $HOME/.config/gtk-3.0/settings.ini) ]]; then
			if [[ ! $(echo $(grep 'gtk-icon-theme-name' $HOME/.config/gtk-3.0/settings.ini | grep "${folder_style}")) ]]; then
				sed -i "s/^gtk-icon-theme-name.*/gtk-icon-theme-name = $folder_style/" $HOME/.config/gtk-3.0/settings.ini
			fi
		else
			echo "gtk-icon-theme-name = $folder_style" >> $HOME/.config/gtk-3.0/settings.ini
		fi
		mkdir -p /etc/gtk-3.0
		cp -f $HOME/.config/gtk-3.0/settings.ini /etc/gtk-3.0/settings.ini
		chmod 644 /etc/gtk-3.0/settings.ini
	fi
	if [ -e $HOME/.config/gtk-4.0/settings.ini ]; then
		if [[ $(grep 'gtk-icon-theme-name' $HOME/.config/gtk-4.0/settings.ini) ]]; then
			if [[ ! $(echo $(grep 'gtk-icon-theme-name' $HOME/.config/gtk-4.0/settings.ini | grep "${folder_style}")) ]]; then
				sed -i "s/^gtk-icon-theme-name.*/gtk-icon-theme-name = $folder_style/" $HOME/.config/gtk-4.0/settings.ini
			fi
		else
			echo "gtk-icon-theme-name = $folder_style" >> $HOME/.config/gtk-4.0/settings.ini
		fi
		mkdir -p /etc/gtk-4.0
		cp -f $HOME/.config/gtk-4.0/settings.ini /etc/gtk-4.0/settings.ini
		chmod 644 /etc/gtk-4.0/settings.ini
	fi
}
export -f perbarui_ikon

# add selected color to list of recently-selected theme colors
tambahkan_ke_terbaru(){
	grep -v $1 $APPDIR/.jcc/recent | tail -8 > /tmp/jcc-recent
	echo $1 >> /tmp/jcc-recent
	mv -f /tmp/jcc-recent $APPDIR/.jcc/recent
}
export -f tambahkan_ke_terbaru

# update background and folder colors
perbarui_latar_belakang(){
	currentcolor=$(cat $APPDIR/.jcc/warnasekarang)
	ganti_tema_umum "$currentcolor"
}
export -f perbarui_latar_belakang

# update background (wallpaper) color selector
perbarui_pemilih_warna(){
	currentcolor=$(cat $APPDIR/.jcc/warnasekarang)
	r=`printf '%d' 0x${currentcolor:1:2}`
	g=`printf '%d' 0x${currentcolor:3:2}`
	b=`printf '%d' 0x${currentcolor:5:2}`
	if [ "$r" -lt 60 ];then r=60;fi
	if [ "$g" -lt 60 ];then g=60;fi
	if [ "$b" -lt 60 ];then b=60;fi
	r3=$(( r - 45 ))
	g3=$(( g - 45 ))
	b3=$(( b - 45 ))
	r3hex=`printf '%02x' $r3`
	g3hex=`printf '%02x' $g3`
	b3hex=`printf '%02x' $b3`
	warnagelap_medium="#$r3hex$g3hex$b3hex"
	echo "$warnagelap_medium" > $APPDIR/.jcc/bg-color
	echo "$warnagelap_medium" > $APPDIR/.jcc/bg-color-bak
}
export -f perbarui_pemilih_warna

# apply background (wallpaper)
terapkan_latar_belakang(){
	bg=$(cat $APPDIR/.jcc/bg 2>/dev/null)
	bg_text_color=$(cat $APPDIR/.jcc/bg-text-color 2>/dev/null)
	[ ! "$bg_text_color" ] && bg_text_color="#FFF-White"
	[ "$bg_text_color" = "#000 (black)" ] && bg_text_color="#000" || bg_text_color="#FFF"
	if [ "$bg" = "true" ]; then
		bg_color=$(cat $APPDIR/.jcc/bg-color 2>/dev/null)
		# get appropriate template for background style
		bg_gradient=$(cat $APPDIR/.jcc/bg-gradient 2>/dev/null)
		[ ! "$bg_gradient" ] && bg_gradient="false"
		bg_gradient_orientation=$(cat $APPDIR/.jcc/bg-gradient-orientation 2>/dev/null)
		[ ! "$bg_gradient_orientation" ] && bg_gradient_orientation="radial"
		custom_gradient_colors=$(cat $APPDIR/.jcc/custom-colors 2>/dev/null)
		[ ! "$custom_gradient_colors" ] && custom_gradient_colors="true"
		bg_label_deco=$(cat $APPDIR/.jcc/bg-label-deco 2>/dev/null)
		[ ! "$bg_label_deco" ] && bg_label_deco="flat"
		if [ "$bg_gradient" = "true" ]; then
			if [ "$bg_gradient_orientation" = "horizontal" ]; then
				if [ "$bg_label_deco" = "no label" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_nolabel.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "flat" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_flat.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "outline" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_outline.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "shadow" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_shadow.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "emboss" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_emboss.svg > $APPDIR/.jcc/bg_template.svg
				fi
			elif [ "$bg_gradient_orientation" = "oblique" ]; then
				if [ "$bg_label_deco" = "no label" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_nolabel.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"100%\" y1=\"100%\" x2=\"0%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "flat" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_flat.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"100%\" y1=\"100%\" x2=\"0%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "outline" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_outline.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"100%\" y1=\"100%\" x2=\"0%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "shadow" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_shadow.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"100%\" y1=\"100%\" x2=\"0%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "emboss" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_emboss.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"100%\" y1=\"100%\" x2=\"0%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				fi
			elif [ "$bg_gradient_orientation" = "vertical" ]; then
				if [ "$bg_label_deco" = "no label" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_nolabel.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "flat" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_flat.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "outline" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_outline.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "shadow" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_shadow.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "emboss" ]; then
					cat $APPDIR/.jcc/templates/bg_template_lgradient_emboss.svg | sed -e "s/<linearGradient.*/<linearGradient id=\"lgrad\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\" >/" > $APPDIR/.jcc/bg_template.svg > $APPDIR/.jcc/bg_template.svg
				fi
			elif [ "$bg_gradient_orientation" = "radial" ]; then
				if [ "$bg_label_deco" = "no label" ]; then
					cat $APPDIR/.jcc/templates/bg_template_rgradient_nolabel.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "flat" ]; then
					cat $APPDIR/.jcc/templates/bg_template_rgradient_flat.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "outline" ]; then
					cat $APPDIR/.jcc/templates/bg_template_rgradient_outline.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "shadow" ]; then
					cat $APPDIR/.jcc/templates/bg_template_rgradient_shadow.svg > $APPDIR/.jcc/bg_template.svg
				elif [ "$bg_label_deco" = "emboss" ]; then
					cat $APPDIR/.jcc/templates/bg_template_rgradient_emboss.svg > $APPDIR/.jcc/bg_template.svg
				fi
			fi
		else
			if [ "$bg_label_deco" = "no label" ]; then
				cat $APPDIR/.jcc/templates/bg_template_nolabel.svg > $APPDIR/.jcc/bg_template.svg
			elif [ "$bg_label_deco" = "flat" ]; then
				cat $APPDIR/.jcc/templates/bg_template_flat.svg > $APPDIR/.jcc/bg_template.svg
			elif [ "$bg_label_deco" = "outline" ]; then
				cat $APPDIR/.jcc/templates/bg_template_outline.svg > $APPDIR/.jcc/bg_template.svg
			elif [ "$bg_label_deco" = "shadow" ]; then
				cat $APPDIR/.jcc/templates/bg_template_shadow.svg > $APPDIR/.jcc/bg_template.svg
			elif [ "$bg_label_deco" = "emboss" ]; then
				cat $APPDIR/.jcc/templates/bg_template_emboss.svg > $APPDIR/.jcc/bg_template.svg
			fi
		fi
		[ ! -d $HOME/.config/wallpaper ] && mkdir -p $HOME/.config/wallpaper
		[ -f /usr/share/backgrounds_original/ORIGINAL-jwmdesk.svg ] && /
		rm -f /usr/share/backgrounds_original/ORIGINAL-jwmdesk.svg
		cp -f $APPDIR/.jcc/bg_template.svg /tmp/tmp.svg
		# make background label
		if [ ! "$bg_label_deco" = "no label" ]; then
			# set label text
			. /etc/DISTRO_SPECS
			DISTRO="$DISTRO_NAME $DISTRO_VERSION"
			bg_label_text=$(cat $APPDIR/.jcc/bg-label-text 2>/dev/null | sed 's/[\&\/\\<>]//g')
			[ ! "$bg_label_text" ] && bg_label_text="$DISTRO_NAME"
			[ "$bg_label_text" = "distro" ] && bg_label_text="$DISTRO_NAME"
			[ "$bg_label_text" = "distro + version" ] && bg_label_text="$DISTRO_NAME $DISTRO_VERSION"
			sed -i -e "s/LABEL/$bg_label_text/" /tmp/tmp.svg
			# set label color (black or white)
			r=`printf '%d' 0x${bg_color:1:2}`
			g=`printf '%d' 0x${bg_color:3:2}`
			b=`printf '%d' 0x${bg_color:5:2}`
			yiq=`echo "(($r*299)+($g*587)+($b*114))/1000"|bc`
			if [ "$yiq" -gt 127 ]; then
				hurufbiasa="#000" # dark label on light background
			else
				hurufbiasa="#FFF" # light label on dark background
			fi
			sed -i -e "s/middle;fill:#ffffff/middle;fill:$hurufbiasa/" /tmp/tmp.svg
			# set font weight
			font_weight=bold # bold or normal
			sed -i -e "s/font-weight:bold/font-weight:$font_weight/g" /tmp/tmp.svg
			# set font style
			font_style=$(cat $APPDIR/.jcc/font-style 2>/dev/null)
			sed -i -e "s/font-style:italic/font-style:$font_style/g" /tmp/tmp.svg
			# set label font specifications
			font_name=$(cat $APPDIR/.jcc/font-name 2>/dev/null)
			sed -i -e "s/font-family:Sans/font-family:$font_name/g" /tmp/tmp.svg
			sed -i -e "s/font-specification:Sans Bold Italic/font-specification:$font_name $font_weight $font_style/g" /tmp/tmp.svg
			# set font size
			font_size=$(cat $APPDIR/.jcc/font-size 2>/dev/null)
			sed -i -e "s/font-size:64/font-size:$font_size/" /tmp/tmp.svg
		fi
		# set background color
		if [ "$bg_gradient" = "true" ]; then
			if [ "$custom_gradient_colors" = "true" ]; then # apply custom colors to background gradient
				bg_color1=$(cat $APPDIR/.jcc/bg-color1 2>/dev/null)
				[ ! "$bg_color1" ] && bg_color1="#0D465F"
				stop_color1="$bg_color1"
				bg_color2=$(cat $APPDIR/.jcc/bg-color2 2>/dev/null)
				[ ! "$bg_color2" ] && bg_color2="#26A269"
				stop_color2="$bg_color2"
			else # apply current JWM theme color to background gradient
				stop_color1="$bg_color"

				r=`printf '%d' 0x${stop_color1:1:2}`
				g=`printf '%d' 0x${stop_color1:3:2}`
				b=`printf '%d' 0x${stop_color1:5:2}`

				r5=$(( r + 45 ))
				g5=$(( g + 45 ))
				b5=$(( b + 45 ))
				if [ "$r5" -gt 255 ];then r5=255;fi
				if [ "$g5" -gt 255 ];then g5=255;fi
				if [ "$b5" -gt 255 ];then b5=255;fi
				r5hex=`printf '%02x' $r5`
				g5hex=`printf '%02x' $g5`
				b5hex=`printf '%02x' $b5`

				stop_color2="#$r5hex$g5hex$b5hex"
			fi
				sed -i -e "s/#1A3B66/$stop_color1/g" /tmp/tmp.svg
				sed -i -e "s/#1F5090/$stop_color2/g" /tmp/tmp.svg
		else
			sed -i -e "s/#1A3B66/$bg_color/g" /tmp/tmp.svg
		fi
		# apply background to desktop
		mv -f /tmp/tmp.svg /usr/share/backgrounds/jwmdesk.svg
		echo 'Stretch' > $HOME/.config/wallpaper/backgroundmode
		[ "$ROX_PINBOARD" ] && sed -i 's/<backdrop style=\".*\">/<backdrop style=\"Stretched\">/' $HOME/Choices/ROX-Filer/PuppyPin
		if [ -d /usr/local/easy_version ]; then
			echo "/usr/share/backgrounds/jwmdesk.png" > $HOME/.config/wallpaper/bg_img
			read ROOTDIMS MX MY << EOF
			`xwininfo -root | grep -F ' -geometry ' | cut -f 1 -d '+' | tr 'x' ' '`
EOF
			[ ! "$MX" ] && MX="1600"
			[ ! "$MY" ] && MY="1200"
			rsvg-convert -w $MX -h $MY -o /usr/share/backgrounds/jwmdesk.png /usr/share/backgrounds/jwmdesk.svg
			rm -f /usr/share/backgrounds/jwmdesk.svg
			. $APPDIR/set_bg "/usr/share/backgrounds/jwmdesk.png"
		else
			echo "/usr/share/backgrounds/jwmdesk.svg" > $HOME/.config/wallpaper/bg_img
			[ -f /tmp/current_wallpaper_selection.jpg ] && rm -f /tmp/current_wallpaper_selection.jpg
			ln -sf /usr/share/backgrounds/jwmdesk.svg /tmp/current_wallpaper_selection.jpg
			. $APPDIR/set_bg "/usr/share/backgrounds/jwmdesk.svg"
		fi
		# apply foreground (text) color to Rox pinboard
		if [ "$ROX_OPTIONS" ]; then
			sed -i -e "s/  <Option name=\"pinboard_fg.*$/  <Option name=\"pinboard_fg_colour\">$bg_text_color<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			sed -i -e "s/  <Option name=\"pinboard_bg.*$/  <Option name=\"pinboard_bg_colour\">$bg_color<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			if [ "$bg_text_color" = "#FFF" ]; then
				sed -i -e "s/  <Option name=\"pinboard_shadow_labels.*$/  <Option name=\"pinboard_shadow_labels\">1<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				sed -i -e "s/  <Option name=\"pinboard_shadow_colour.*$/  <Option name=\"pinboard_shadow_colour\">#000<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			elif [ "$bg_text_color" = "#000" ]; then
				sed -i -e "s/  <Option name=\"pinboard_shadow_labels.*$/  <Option name=\"pinboard_shadow_labels\">0<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			fi
		fi
	else
		echo "#EBEBEB" > $APPDIR/.jcc/bg-color-bak
		if [ "$ROX_OPTIONS" ]; then
			sed -i -e "s/  <Option name=\"pinboard_fg.*$/  <Option name=\"pinboard_fg_colour\">$bg_text_color<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			sed -i -e "s/  <Option name=\"pinboard_bg.*$/  <Option name=\"pinboard_bg_colour\">#EBEBEB<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			if [ "$bg_text_color" = "#FFF" ]; then
				sed -i -e "s/  <Option name=\"pinboard_shadow_labels.*$/  <Option name=\"pinboard_shadow_labels\">1<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				sed -i -e "s/  <Option name=\"pinboard_shadow_colour.*$/  <Option name=\"pinboard_shadow_colour\">#000<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			elif [ "$bg_text_color" = "#000" ]; then
				sed -i -e "s/  <Option name=\"pinboard_shadow_labels.*$/  <Option name=\"pinboard_shadow_labels\">0<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			fi
		fi
	fi
}
export -f terapkan_latar_belakang

# restore original Roxfiler folder and GTK icons
folder_asli(){
	if [ -d /usr/share/icons/"Puppy Standard" ]; then
		for i in 16 22 24 32 48 64; do
			cat $APPDIR/icons/folders/folder-puppystandard-bak.svg | sed "s/256px/${i}px/g" > /usr/share/icons/"Puppy Standard"/${i}/places/directory.svg
		done
		cat $APPDIR/icons/folders/folder-puppystandard-bak.svg > /usr/share/icons/"Puppy Standard"/scalable/places/directory.svg
	fi
	if [ -d /usr/share/icons/"PMaterial" ]; then
		for i in 16 22 24 32 48 64; do
			cat $APPDIR/icons/folders/folder-pmaterial-bak.svg | sed "s/256px/${i}px/g" > /usr/share/icons/"PMaterial"/${i}/places/directory.svg
		done
		cat $APPDIR/icons/folders/folder-pmaterial-bak.svg > /usr/share/icons/"PMaterial"/scalable/places/directory.svg
	fi
	if [ -d /usr/share/icons/"Puppy Flat" ]; then
		for i in 16 22 24 32 48 64; do
			cat $APPDIR/icons/folders/folder-puppyflat-bak.svg | sed "s/256px/${i}px/g" > /usr/share/icons/"Puppy Flat"/${i}/places/directory.svg
		done
		cat $APPDIR/icons/folders/folder-puppyflat-bak.svg > /usr/share/icons/"Puppy Flat"/scalable/places/directory.svg
	fi
}
export -f folder_asli

# set new RoxFiler folder and GTK icons
folder_baru(){
	folder_asli
	sed -i -e "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">$folder_style<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
	for i in 16 22 24 32 48 64; do
		cat $APPDIR/icons/folders/$folder_template | sed -e "s/"$color_template"/"$folder_color"/g" -e "s/256px/${i}px/g" > /usr/share/icons/"$folder_style"/${i}/places/directory.svg
	done
	cat $APPDIR/icons/folders/$folder_template | sed -e "s/"$color_template"/"$folder_color"/g" > /usr/share/icons/"$folder_style"/scalable/places/directory.svg
	cat $APPDIR/icons/folders/$folder_template | sed -e "s/"$color_template"/"$folder_color"/g" > /tmp/tmp48.svg
}
export -f folder_baru

# add selected color to RoxFiler folder, and optionally match the new (baru) jwm theme
ganti_warna_folder(){
	folder=$(cat $APPDIR/.jcc/folder 2>/dev/null)
	folder_style=$(cat $APPDIR/.jcc/folder-style 2>/dev/null)
	folder_color=$(cat $APPDIR/.jcc/folder-color 2>/dev/null)
	folder_color2=$(cat $APPDIR/.jcc/folder-color2 2>/dev/null)
	folder_color3=$(cat $APPDIR/.jcc/folder-color3 2>/dev/null)

	desktop_icon_theme=$(cat /etc/desktop_icon_theme 2>/dev/null)
	[ ! "$desktop_icon_theme" ] && desktop_icon_theme="StandardSvg"

	if [ "$folder" = "true" ]; then # set style and color of folder icon
		if [ "$folder_style" = "Desktop" ] || [ "$folder_style" = "" ]; then # set folder icon defined in /etc/desktop_icon_theme
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			if [ -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder48.png ]; then
				cp -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder48.png /usr/local/lib/X11/pixmaps
				cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png
			elif [ -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder.svg ]; then
				cp -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder.svg /tmp/tmp48.svg 
				rsvg-convert -w 100 -h 100 -o /tmp/tmp48.png /tmp/tmp48.svg
				mv -f /tmp/tmp48.png /usr/local/lib/X11/pixmaps/folder48.png
				cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png # legacy hack
			fi
			folder_asli
		elif [ "$folder_style" = "Adwaita" ]; then # Adwaita icon theme
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">Adwaita<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			cp -f /usr/share/icons/Adwaita/512x512/places/folder.png /usr/local/lib/X11/pixmaps/folder48.png
			cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png
			folder_asli
			perbarui_ikon
		else # set folder icon defined in Puppy-specific icon themes, or set Legacy/Modern/Accent/Buntu/Buntu Light folder icon
			if [ "$folder_style" = "Puppy Standard" ]; then
				color_template="#E8DC88"
				folder_template="folder-puppystandard.svg"
				if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
					folder_baru
					perbarui_ikon
				else
					sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
					cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg
					sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				fi
			elif [ "$folder_style" = "PMaterial" ]; then
				color_template="#088278"
				folder_template="folder-pmaterial.svg"
				if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
					folder_baru
					perbarui_ikon
				else
					sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
					cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg
					sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				fi
			elif [ "$folder_style" = "Puppy Flat" ]; then
				color_template="#D2C179"
				folder_template="folder-puppyflat.svg"
				if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
					folder_baru
					perbarui_ikon
				else
					sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
					cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg
					sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				fi
			elif [ "$folder_style" = "Legacy" ]; then
				color_template="#DFC785"
				folder_template="folder-legacy.svg"
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg 
				sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				folder_asli
			elif [ "$folder_style" = "Modern" ]; then
				color_template="#DFC785"
				folder_template="folder-modern.svg"
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg 
				sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				folder_asli
			elif [ "$folder_style" = "Accent" ]; then
				color_template="#B09C68"
				folder_template="folder-accent.svg"
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg 
				sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				folder_asli
			elif [ "$folder_style" = "Buntu" ]; then
				color_template="#DFC785"
				color_template2="#B09C68"
				color_template3="#B09C69"
				folder_template="folder-accent.svg"
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg 
				sed -i -e "s/"$color_template"/"$folder_color"/g" /tmp/tmp48.svg
				sed -i -e "s/"$color_template2"/"$folder_color2"/g" /tmp/tmp48.svg
				sed -i -e "s/"$color_template3"/"$folder_color3"/g" /tmp/tmp48.svg
				folder_asli
			elif [ "$folder_style" = "Buntu Light" ]; then
				color_template="#DFC785"
				color_template2="#B09C68"
				color_template3="#B09C69"
				folder_template="folder-accent.svg"
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
				cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg 
				sed -i -e "s/"$color_template"/"$folder_color2"/g" /tmp/tmp48.svg
				sed -i -e "s/"$color_template2"/"$folder_color"/g" /tmp/tmp48.svg
				sed -i -e "s/"$color_template3"/"$folder_color3"/g" /tmp/tmp48.svg
				folder_asli
			fi
			rsvg-convert -w 100 -h 100 -o /tmp/tmp48.png /tmp/tmp48.svg
			mv -f /tmp/tmp48.png /usr/local/lib/X11/pixmaps/folder48.png
			cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png # legacy hack
		fi
	else # reset default folder style and color
		if [ "$folder_style" = "Desktop" ]; then
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			icon_theme="ROX"
		elif [ "$folder_style" = "Puppy Standard" ]; then
			folder_template="folder-puppystandard-bak.svg"
			if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
				sed -i -e "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">$folder_style<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options  
			else
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			fi
			icon_theme="Puppy Standard"
		elif [ "$folder_style" = "PMaterial" ]; then
			folder_template="folder-pmaterial-bak.svg"
			if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
				sed -i -e "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">$folder_style<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options  
			else
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			fi
			icon_theme="PMaterial"
		elif [ "$folder_style" = "Puppy Flat" ]; then
			folder_template="folder-puppyflat-bak.svg"
			if [ -f /usr/share/icons/"$folder_style"/scalable/places/directory.svg ]; then
				sed -i -e "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">$folder_style<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options 
			else
				sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			fi 
			icon_theme="Puppy Flat"
		elif [ "$folder_style" = "Legacy" ]; then
			folder_template="folder-legacy-bak.svg"
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options 
			icon_theme="Legacy"
		elif [ "$folder_style" = "Modern" ]; then
			folder_template="folder-modern-bak.svg"
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options 
			icon_theme="Modern"
		elif [ "$folder_style" = "Accent" -o "$folder_style" = "Buntu" -o "$folder_style" = "Buntu Light" ]; then
			folder_template="folder-accent-bak.svg"
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options 
			icon_theme="Accent"
		else
			sed -i "s/  <Option name=\"icon_theme\">.*$/  <Option name=\"icon_theme\">ROX<\/Option>/" $HOME/.config/rox.sourceforge.net/ROX-Filer/Options
			icon_theme="ROX"
		fi
		[ ! "$folder_style" = "Desktop" -a ! "$folder_style" = "Adwaita" ] && cp -f $APPDIR/icons/folders/$folder_template /tmp/tmp48.svg
		folder_asli
		if [ "$icon_theme" = "Puppy Standard" ] || [ "$icon_theme" = "PMaterial" ] || [ "$icon_theme" = "Puppy Flat" ] || [ "$icon_theme" = "Legacy" ] || [ "$icon_theme" = "Modern" ] || [ "$icon_theme" = "Accent" ] || [ "$icon_theme" = "Buntu" ] || [ "$icon_theme" = "Buntu Light" ]; then # reset original folder icon
			rsvg-convert -w 100 -h 100 -o /tmp/tmp48.png /tmp/tmp48.svg
			mv -f /tmp/tmp48.png /usr/local/lib/X11/pixmaps/folder48.png
			cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png # legacy hack
		else # reset folder icon defined in /etc/desktop_icon_theme
			if [ -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder48.png ]; then
				cp -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder48.png /usr/local/lib/X11/pixmaps
				cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png
			elif [ -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder.svg ]; then
				cp -f /usr/local/lib/X11/themes/"$desktop_icon_theme"/folder.svg /tmp/tmp48.svg 
				rsvg-convert -w 100 -h 100 -o /tmp/tmp48.png /tmp/tmp48.svg
				mv -f /tmp/tmp48.png /usr/local/lib/X11/pixmaps/folder48.png
				cp -f /usr/local/lib/X11/pixmaps/folder48.png /usr/local/lib/X11/pixmaps/folders24.png # legacy hack
			fi
		fi
		echo "#EBEBEB" > $APPDIR/.jcc/folder-color
	fi
	[ ! -h $HOME/.icons/ROX/MIME/inode-directory.png ] && cp -f /usr/local/lib/X11/pixmaps/folder48.png $HOME/.icons/ROX/MIME/inode-directory.png
	[ -h "$HOME/.DirIcon" ] && rm -f "$HOME/.DirIcon"
	for dir in Documents Downloads my-documents my-applications network Music Video Images ; do
		[ -h "$HOME/$dir/.DirIcon" ] && rm -f "$HOME/$dir/.DirIcon"
	done
}
export -f ganti_warna_folder

# add selected color to new JWM theme, and optionally to background (wallpaper) and RoxFiler folder
ganti_tema_umum(){
	warnaterang="$1"
	
	[ ! $(echo "$warnaterang" | grep -E '^#[[:xdigit:]]{6}$') ] && \
	gtkdialog-splash -close never -timeout 5 -margin 10 -placement center -fontsize large -bg goldenrod -text " $(gettext 'Please enter color in hexadecimal format !') " && exit 0

	[ ! "$ROX_OPTIONS" ] && folder_color="#EBEBEB" && echo "#EBEBEB" > $APPDIR/.jcc/folder-color

	folder_only=$(cat $APPDIR/.jcc/folder-only 2>/dev/null)
	[ ! "$folder_only" ] && folder_only="false"
	if [ "$folder_only" = "true" ]; then # apply folder color, but do not apply JWM or background colors
		# parse selected folder options
		ganti_warna_folder
		# apply selected folder color
		[ -x /usr/local/bin/roxfiler ] && ROX=roxfiler || ROX=rox
		if pidof ROX-Filer >/dev/null 2>&1; then
			HOMEDIR=`echo $HOME`
			ROX_OPEN="$(xwininfo -root -tree 2>/dev/null | grep -i 'ROX' | awk '{print $2}' | grep -Evi 'ROX|has|bugfix' | sed -e 's/[\(";:\)]//g' -e "s%\~%$HOMEDIR%g")" # store open rox windows 
			killall ROX-Filer
			sleep 1
			[ "$ROX_PINBOARD" ] && $ROX -p $HOME/Choices/ROX-Filer/PuppyPin
			sync
			for d in `echo $ROX_OPEN` ; do
				[ -d $d ] && $ROX $d 2>/dev/null
			done # re-open killed windows
		fi
		exit 0
	fi

	# warna_terang (bright color) - generate window active background (and RoxFiler folder color)
	r=`printf '%d' 0x${warnaterang:1:2}`
	g=`printf '%d' 0x${warnaterang:3:2}`
	b=`printf '%d' 0x${warnaterang:5:2}`

	if [ "$r" -lt 60 ];then r=60;fi
	if [ "$g" -lt 60 ];then g=60;fi
	if [ "$b" -lt 60 ];then b=60;fi

	yiq=`echo "(($r*299)+($g*587)+($b*114))/1000"|bc`

	rhex=`printf '%02x' $r`
	ghex=`printf '%02x' $g`
	bhex=`printf '%02x' $b`

	warnaterang="#$rhex$ghex$bhex"

	# warna_x_terang (xtra-bright color) - generate menu active background color
	r0=$(( r + 25 ))
	g0=$(( g + 25 ))
	b0=$(( b + 25 ))

	if [ "$r0" -gt 255 ];then r0=255;fi
	if [ "$g0" -gt 255 ];then g0=255;fi
	if [ "$b0" -gt 255 ];then b0=255;fi

	r0hex=`printf '%02x' $r0`
	g0hex=`printf '%02x' $g0`
	b0hex=`printf '%02x' $b0`

	warnaxterang="#$r0hex$g0hex$b0hex"
	echo "$warnaxterang" > $APPDIR/.jcc/folder-color2

	# warna_biasa (normal color) - generate menu background and tray active background color
	r1=$(( r - 30 ))
	g1=$(( g - 30 ))
	b1=$(( b - 30 ))

	yiq1=`echo "(($r1*299)+($g1*587)+($b1*114))/1000"|bc`

	r1hex=`printf '%02x' $r1`
	g1hex=`printf '%02x' $g1`
	b1hex=`printf '%02x' $b1`

	warnabiasa="#$r1hex$g1hex$b1hex"

	# warna_gelap (dark color) - generate tray background color
	r2=$(( r - 60 ))
	g2=$(( g - 60 ))
	b2=$(( b - 60 ))

	yiq2=`echo "(($r2*299)+($g2*587)+($b2*114))/1000"|bc`

	r2hex=`printf '%02x' $r2`
	g2hex=`printf '%02x' $g2`
	b2hex=`printf '%02x' $b2`

	warnagelap="#$r2hex$g2hex$b2hex"

	# warna_gelap_medium (medium-dark color) - generate background (wallpaper) color to match the new jwm theme color
	r3=$(( r - 45 ))
	g3=$(( g - 45 ))
	b3=$(( b - 45 ))

	r3hex=`printf '%02x' $r3`
	g3hex=`printf '%02x' $g3`
	b3hex=`printf '%02x' $b3`

	warnagelap_medium="#$r3hex$g3hex$b3hex"
	echo "$warnagelap_medium" > $APPDIR/.jcc/folder-color3
	bg_color=$(cat $APPDIR/.jcc/bg-color 2>/dev/null)
	if [ -z "$bg_color" ]; then
		bg_color="$warnagelap_medium"
		echo "$warnagelap_medium" > $APPDIR/.jcc/bg-color
		echo "$warnagelap_medium" > $APPDIR/.jcc/bg-color-bak
	fi

	# huruf_terang (bright characters) - generate window active foreground and menu active foreground color
	if [ "$yiq" -gt 127 ];then
		hurufterang="#000"
	else
		hurufterang="#FFF"
	fi

	# huruf_biasa (normal characters) - generate menu foreground and tray active foreground color
	if [ "$yiq1" -gt 127 ];then
		hurufbiasa="#000"
	else
		hurufbiasa="#FFF"
	fi

	# huruf_gelap (dark characters) - generate tray foreground color
	if [ "$yiq2" -gt 127 ];then
		hurufgelap="#000"
	else
		hurufgelap="#FFF"
	fi

	# apply background colors to the new (baru) jwm theme
	window_only=$(cat $APPDIR/.jcc/window-only 2>/dev/null)
	transparent_tray=$(cat $APPDIR/.jcc/transparent-tray 2>/dev/null)
	if [ "$window_only" = "true" ]; then # apply selected jwm color to active window border and active menu background (apply contrasting dark background to inactive menu and tray)
		dark_color=$(cat $APPDIR/.jcc/dark-color 2>/dev/null)
		[ ! "$dark_color" ] && dark_color="#333333"
		sed "s/warna_biasa/$dark_color/g" $APPDIR/.jcc/$JWMRC > $APPDIR/.jcc/jwmrc-theme-baru
		flat_style=$(cat $APPDIR/.jcc/flat-style 2>/dev/null)
		[ ! "$flat_style" ] && flat_style="false"
		if [ "$flat_style" = "true" ]; then # flat colors
			sed -i "s/warnaterang/$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_terang/$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_x_terang/$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			if [ "$transparent_tray" = "true" ]; then
				sed -i "s/warna_gelap/$bg_color/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/huruf_gelap/$hurufbiasa/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/kegelapan/0.85/" $APPDIR/.jcc/jwmrc-theme-baru
			else
				sed -i "s/warna_gelap/$dark_color/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "/kegelapan/d" $APPDIR/.jcc/jwmrc-theme-baru
			fi
		else # gradient colors
			sed -i "s/warnaterang/$warnaterang:$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_terang/$warnaterang:$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_x_terang/$warnaterang:$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
			if [ "$transparent_tray" = "true" ]; then
				sed -i "s/warna_gelap/$bg_color/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/huruf_gelap/$hurufbiasa/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/kegelapan/0.85/" $APPDIR/.jcc/jwmrc-theme-baru
			else
				sed -i "s/warna_gelap/$dark_color:#000000/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "/kegelapan/d" $APPDIR/.jcc/jwmrc-theme-baru
			fi
		fi
		# apply foreground colors to the new (baru) jwm theme
		sed -i "s/huruf_biasa/#D2CFD2/g" $APPDIR/.jcc/jwmrc-theme-baru
		sed -i "s/huruf_terang/$hurufterang/g" $APPDIR/.jcc/jwmrc-theme-baru
		sed -i "s/huruf_gelap/#D2CFD2/g" $APPDIR/.jcc/jwmrc-theme-baru
	else # apply selected jwm color to window border, menu and tray
		sed "s/warna_biasa/$warnabiasa/g" $APPDIR/.jcc/$JWMRC > $APPDIR/.jcc/jwmrc-theme-baru
		flat_style=$(cat $APPDIR/.jcc/flat-style 2>/dev/null)
		[ ! "$flat_style" ] && flat_style="false"
		if [ "$flat_style" = "true" ]; then # flat colors
			sed -i "s/warnaterang/$warnaxterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_terang/$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_x_terang/$warnaxterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			if [ "$transparent_tray" = "true" ]; then
				sed -i "s/warna_gelap/$bg_color/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/huruf_gelap/$hurufbiasa/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/kegelapan/0.85/" $APPDIR/.jcc/jwmrc-theme-baru
			else
				sed -i "s/warna_gelap/$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "/kegelapan/d" $APPDIR/.jcc/jwmrc-theme-baru
			fi
		else # gradient colors
			sed -i "s/warnaterang/$warnaxterang:$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_terang/$warnaterang:$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
			sed -i "s/warna_x_terang/$warnaxterang:$warnaterang/g" $APPDIR/.jcc/jwmrc-theme-baru
			if [ "$transparent_tray" = "true" ]; then
				sed -i "s/warna_gelap/$bg_color/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/huruf_gelap/$hurufbiasa/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "s/kegelapan/0.85/" $APPDIR/.jcc/jwmrc-theme-baru
			else
				sed -i "s/warna_gelap/$warnaterang:$warnagelap/g" $APPDIR/.jcc/jwmrc-theme-baru
				sed -i "/kegelapan/d" $APPDIR/.jcc/jwmrc-theme-baru
			fi
		fi
		# apply foreground colors to the new (baru) jwm theme
		sed -i "s/huruf_biasa/$hurufbiasa/g" $APPDIR/.jcc/jwmrc-theme-baru
		sed -i "s/huruf_terang/$hurufterang/g" $APPDIR/.jcc/jwmrc-theme-baru
		sed -i "s/huruf_gelap/$hurufgelap/g" $APPDIR/.jcc/jwmrc-theme-baru
	fi

	# apply folder color to match the new (baru) jwm theme
	[ "$ROX_OPTIONS" ] && ganti_warna_folder

	# apply background (wallpaper) label and color to match the new (baru) jwm theme
	terapkan_latar_belakang

	# If exist, preserve Clockstyle tag
	if [ ! "`grep -aF -- '<ClockStyle>' $APPDIR/.jcc/jwmrc-theme-baru 2>/dev/null`" ]; then
		if [ "`grep -aF -- '<ClockStyle>' $HOME/.jwm/jwmrc-theme 2>/dev/null`" ]; then
			sed -n '/<ClockStyle>/,/<\/ClockStyle>$/p' $HOME/.jwm/jwmrc-theme > /tmp/clockstyle
			grep -v '</JWM>' $APPDIR/.jcc/jwmrc-theme-baru > /tmp/tmp
			echo -e "$(cat /tmp/clockstyle)\n\n</JWM>" >> /tmp/tmp
			mv -f /tmp/tmp $APPDIR/.jcc/jwmrc-theme-baru
		fi
	fi

	# make new jwm theme the current default
	cp -f $APPDIR/.jcc/jwmrc-theme-baru $HOME/.jwm/jwmrc-theme

	# save selected color to jcc and jwm RC files
	COLOR=$(echo "$warnaterang" | tr '[:lower:]' '[:upper:]')
	tambahkan_ke_terbaru $COLOR
	echo "$COLOR" > $APPDIR/.jcc/warnasekarang
	if [ -d /usr/share/jwm/themes ]; then #jwm_config desktop
		echo "Color: $COLOR" > $HOME/.jwm/tray_active_preset
		echo "Color: $COLOR" > $HOME/.jwm/theme
	else # legacy jwm desktop
		echo "Color: $COLOR" > $HOME/.jwm/theme
	fi

	# update legacy color selector button
	echo '<svg height="30" width="30"><path d="M0 0h30v30H0z" fill="'$COLOR'" stroke="#FFFFFF" stroke-width="1.5"/></svg>' > $APPDIR/icons/colorbutton.svg

	# apply new jwm theme
	[ -x /usr/local/bin/roxfiler ] && ROX=roxfiler || ROX=rox
	if pidof ROX-Filer >/dev/null 2>&1; then
		HOMEDIR=`echo $HOME`
		ROX_OPEN="$(xwininfo -root -tree 2>/dev/null | grep -i 'ROX' | awk '{print $2}' | grep -Evi 'ROX|has|bugfix' | sed -e 's/[\(";:\)]//g' -e "s%\~%$HOMEDIR%g")" # store open rox windows 
		killall ROX-Filer
		[ "$ROX_PINBOARD" ] && $ROX -p $HOME/Choices/ROX-Filer/PuppyPin
		sync
		for d in `echo $ROX_OPEN` ; do
			[ -d $d ] && $ROX $d 2>/dev/null
		done # re-open killed windows
	fi
	sleep 1
	jwm -restart &
}
export -f ganti_tema_umum

# create recent-color buttons
warna_terbaru(){
	touch $APPDIR/.jcc/recent
	if [ "`cat $APPDIR/.jcc/recent`" != "" ];then
	echo '<text xalign="0"><label>"'"$(gettext 'Recent colors:')"'"</label></text>'
	echo '<hbox spacing="0" homogeneous="true">'

	while read warna;do
	echo '<svg height="35" width="'$svg_width'"><path d="'$svg_path'" fill="'$warna'" stroke="#333" stroke-width="1"/></svg>' > $APPDIR/.jcc/warna/$warna
	echo '	<button relief="2" image-position="2" tooltip-text=" '"$warna"' ">
		<action>echo > '$APPDIR'/.jcc/bg-color</action>
		<action>echo > '$APPDIR'/.jcc/bg-color-bak</action>
		<action>echo "'"$warna"'" > '$APPDIR'/.jcc/folder-color</action>
		<action>ganti_tema_umum "'$warna'"</action>
		<action>refresh:warna</action>
		<action>refresh:warna2</action>
		<action>refresh:bg_color</action>
		<action>refresh:folder_color</action>
		<input file>'$APPDIR'/.jcc/warna/'$warna'</input>
	</button>'

	done < $APPDIR/.jcc/recent

	n=`wc -l $APPDIR/.jcc/recent|cut -d" " -f1`
	spacer_width=$(( $svg_width + 10 ))
	while [[ $n -le 8 ]];do
		echo '<text space-expand="false" space-fill="false" width-request="'$spacer_width'"><label>" "</label></text>'
		n=$(( $n + 1 ))
	done

	echo '</hbox>'

	fi
}
export -f warna_terbaru

# create favorite-color buttons
warna_kesukaan(){
	mkdir -p $APPDIR/.jcc/warna

	j=1
	k=1
	n=`wc -l $APPDIR/.jcc/warna_wdz_all|cut -d" " -f1`
	n=$(( $n - 1 ))

	echo '<text xalign="0"><label>"'"$(gettext 'Favorite colors:')"'"</label></text>'
	echo '<vbox spacing="0" homogeneous="true">'
	echo '<hbox spacing="0" homogeneous="true">'
	while read i;do
	hex=`echo $i|cut -d"|" -f1`
	name=`echo $i|cut -d"|" -f2`
	echo '<svg height="35" width="'$svg_width'"><path d="'$svg_path'" fill="'$hex'" stroke="#333" stroke-width="1"/></svg>' > $APPDIR/.jcc/warna/$hex
	echo '	<button relief="2" image-position="2" tooltip-text=" '"$name: $hex"' ">
		<action>echo > '$APPDIR'/.jcc/bg-color</action>
		<action>echo > '$APPDIR'/.jcc/bg-color-bak</action>
		<action>echo "'"$hex"'" > '$APPDIR'/.jcc/folder-color</action>
		<action>ganti_tema_umum "'$hex'"</action>
		<action>refresh:warna</action>
		<action>refresh:warna2</action>
		<action>refresh:bg_color</action>
		<action>refresh:folder_color</action>
		<input file>'$APPDIR'/.jcc/warna/'$hex'</input>
	</button>'

	if [ "$k" -lt "$n" ] && [ "$j" -eq 9 ];then
	echo '</hbox>
	<hbox spacing="0" homogeneous="true">'
	fi

	j=$(( $j % 9 ))
	((j++))
	((k++))

	done < $APPDIR/.jcc/warna_wdz_all

	echo '</hbox>'
	echo '</vbox>'
	echo '
	<hseparator space-expand="false" space-fill="false"></hseparator>'
}
export -f warna_kesukaan

# legacy GTK2 color selector for the GTK3 desktop (configured as replacement for GTK3 color selector)
pemilih_warna(){
	CURRCOLOR=`cat $APPDIR/.jcc/warnasekarang 2>/dev/null`
	[ -z "$CURRCOLOR" ] && CURRCOLOR="#3C7C99"
	r=`printf '%d' 0x${CURRCOLOR:1:2}`
	g=`printf '%d' 0x${CURRCOLOR:3:2}`
	b=`printf '%d' 0x${CURRCOLOR:5:2}`
	REPLY=$(Xdialog --title "JWM theme color" --buttons-style text --ok-label " Apply " --cancel-label " Quit " --stdout --colorsel " " 0 0 $r $g $b )
	if [ "$REPLY" = "" ]; then
		$APPDIR/jcc &
	else
		warna=#$(printf "%02X%02X%02X\n" $REPLY)
		echo "$warna" > $APPDIR/.jcc/folder-color
		echo > $APPDIR/.jcc/bg-color
		echo > $APPDIR/.jcc/bg-color-bak
		ganti_tema_umum "$warna"
		sleep 1
		$APPDIR/jcc &
	fi
}
export -f pemilih_warna

# legacy background (wallpaper) application
aplikasi_wallpaper(){
	[ -f /usr/sbin/qwallpaper ] && qwallpaper && exit 0
	wallpaper_option=$(cat $APPDIR/.jcc/wallpaper 2>/dev/null)
	if [ "$wallpaper_option" = "Qwallpaper" ]; then
			$APPDIR/qwallpaper &
	else
		if [ -f /usr/local/apps/Wallpaper/AppRun ]; then
			/usr/local/apps/Wallpaper/AppRun &
		else
			$APPDIR/qwallpaper &
		fi
	fi
}
export -f aplikasi_wallpaper

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

# if no user-selected color, then make #3C7C99 the default color (cool blue)
	[ ! -f $APPDIR/.jcc/warnasekarang ] && echo "#3C7C99" > $APPDIR/.jcc/warnasekarang

# define colorbuttons toggle
	colorbuttons=$(cat $APPDIR/.jcc/colorbuttons 2>/dev/null)
	[ ! "$colorbuttons" ] && colorbuttons="false" && echo "false" > $APPDIR/.jcc/colorbuttons

# define optional flat style for jwm menu, tray and windows (otherwise gradient style)
	flat_style=$(cat $APPDIR/.jcc/flat-style 2>/dev/null)
	[ ! "$flat_style" ] && flat_style="false" && echo "$flat_style" > $APPDIR/.jcc/flat-style

# define window-only option for selected jwm color
	window_only=$(cat $APPDIR/.jcc/window-only 2>/dev/null)
	[ ! "$window_only" ] && window_only="false" && echo "$window_only" > $APPDIR/.jcc/window-only
	[ "$window_only" = "true" ] && ss0="true" || ss0="false"

# define dark-color option for menu and tray (overrides selected jwm color when window-only option is enabled)
	dark_color=$(cat $APPDIR/.jcc/dark-color 2>/dev/null)
	if [ ! "$dark_color" ]; then
		if [ "$window_only" = "true" ]; then
			dark_color="#333333"
		else
			dark_color="#EBEBEB"
		fi
		echo "$dark_color" > $APPDIR/.jcc/dark-color
		echo "#333333" > $APPDIR/.jcc/dark-color-bak
	fi
	[ ! -f $APPDIR/.jcc/dark-color-bak ] && echo "#333333" > $APPDIR/.jcc/dark-color-bak

# define background and label options
	bg=$(cat $APPDIR/.jcc/bg 2>/dev/null)
	[ ! "$bg" ] && bg="false" && echo "false" > $APPDIR/.jcc/bg
	[ "$bg" = "true" ] && ss00="true" ss1="true" ss2="true" ss3="true" ss4="true" || ss00="false" ss1="false" ss2="false" ss3="false" ss4="false" echo "false" > $APPDIR/.jcc/transparent-tray

	bg_solid_color=$(cat $APPDIR/.jcc/bg-solid-color 2>/dev/null)
	[ ! "$bg_solid_color" ] && bg_solid_color="false" && echo "false" > $APPDIR/.jcc/bg-solid-color

	bg_gradient=$(cat $APPDIR/.jcc/bg-gradient 2>/dev/null)
	[ ! "$bg_gradient" ] && bg_gradient="false" && echo "false" > $APPDIR/.jcc/bg-gradient
	[ "$bg_gradient" = "true" ] && ss3="false" || ss3="true"
	[ "$bg" = "false" ] && ss3="false"

	if [ "$bg" = "true" ] && [ "$bg_solid_color" != "true" ] && [ "$bg_gradient" != "true" ]; then
		bg_solid_color="true" && echo "true" > $APPDIR/.jcc/bg-solid-color 
	fi

	bg_color=$(cat $APPDIR/.jcc/bg-color 2>/dev/null)
	if [ ! "$bg_color" ]; then
		bg_color="#0F4F6C"
		echo "#0F4F6C" > $APPDIR/.jcc/bg-color
		echo "#0F4F6C" > $APPDIR/.jcc/bg-color-bak
	fi
	bg_label=$(cat $APPDIR/.jcc/bg-label 2>/dev/null)
	[ ! "$bg_label" ] && bg_label="false" && echo "false" > $APPDIR/.jcc/bg-label

	bg_label_text=$(cat $APPDIR/.jcc/bg-label-text 2>/dev/null)
	[ ! "$bg_label_text" ] && bg_label_text="distro" && echo "distro" > $APPDIR/.jcc/bg-label-text

	bg_label_deco=$(cat $APPDIR/.jcc/bg-label-deco 2>/dev/null)
	[ ! "$bg_label_deco" ] && bg_label_deco="flat" && echo "flat" > $APPDIR/.jcc/bg-label-deco

# define legacy background (wallpaper) application
	wallpaper_option=$(cat $APPDIR/.jcc/wallpaper 2>/dev/null)
	[ ! "$wallpaper_option" ] && wallpaper_option="Nathan Wallpaper" && echo "$wallpaper_option" > $APPDIR/.jcc/wallpaper

# define font options
	font_name=$(cat $APPDIR/.jcc/font-name 2>/dev/null)
	[ ! "$font_name" ] && font_name="Sans" && echo "Sans" > $APPDIR/.jcc/font-name
	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')
	[ ! "$font_name_items" ] && font_name_items="<item>Sans</item>"

	font_size=$(cat $APPDIR/.jcc/font-size 2>/dev/null)
	[ ! "$font_size" ] && font_size="72" && echo "72" > $APPDIR/.jcc/font-size

	font_style=$(cat $APPDIR/.jcc/font-style 2>/dev/null)
	[ ! "$font_style" ] && font_style="italic" && echo "italic" > $APPDIR/.jcc/font-style

# define RoxFiler folder options
	folder=$(cat $APPDIR/.jcc/folder 2>/dev/null)
	[ ! "$ROX_OPTIONS" ] && folder="false" && echo "false" > $APPDIR/.jcc/folder
	[ ! "$folder" ] && folder="false" && echo "false" > $APPDIR/.jcc/folder
	[ "$folder" = "true" ] && ss5="true" || ss5="false"

	folder_only=$(cat $APPDIR/.jcc/folder-only 2>/dev/null)
	[ ! "$folder_only" ] && folder_only="false" && echo "false" > $APPDIR/.jcc/folder-only

	folder_color=$(cat $APPDIR/.jcc/folder-color 2>/dev/null)
	[ ! "$ROX_OPTIONS" ] && folder_color="#EBEBEB" && echo "#EBEBEB" > $APPDIR/.jcc/folder-color
	[ ! "$folder_color" ] && folder_color="#EBEBEB" && echo "#EBEBEB" > $APPDIR/.jcc/folder-color

	folder_style=$(cat $APPDIR/.jcc/folder-style 2>/dev/null)
	[ ! "$folder_style" ] && folder_style="Legacy" && echo "Legacy" > $APPDIR/.jcc/folder-style

	[ "$ROX_OPTIONS" ] && FOLDER_STATE="true" || FOLDER_STATE="false"

# define legacy color selector
	[ ! -f $APPDIR/icons/colorbutton.svg ] && echo '<svg height="30" width="30"><path d="M0 0h40v40H0z" fill="#3C7C99" stroke="#FFFFFF" stroke-width="1.5"/></svg>' > $APPDIR/icons/colorbutton.svg

# set color selector for GTK3 Puppy
	button_colorsel=''
	button_colorsel2=''
	if [ "`ldd $(which gtkdialog) | grep -Fi 'gtk-3' 2>/dev/null`" ]; then # GTK3 environment
		if [ "`which gtk2dialog 2>/dev/null`" ]; then
			# toggle option for GTK2/GTK3 color selector in GTK3 environment
			[ "$gtk2_dialog" = "true" ] && toggled_gtk="GTK3" || toggled_gtk="GTK2"
			button_colorsel='
			<togglebutton space-expand="false" space-fill="false" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Switch color selector to') $toggled_gtk"' ">
				<input file>'$APPDIR'/icons/color-selector.svg</input><height>30</height><width>30</width>
				<variable>gtk2_dialog</variable>
				<default>'$gtk2_dialog'</default>
				<action>if true echo true > '$APPDIR'/.jcc/gtk2-dialog</action>
				<action>if false echo false > '$APPDIR'/.jcc/gtk2-dialog</action>
				<action>'$APPDIR'/jcc &</action>
				<action>exit:quit_now</action>
			</togglebutton>'
		else
			# optional GTK2 color selector in GTK3 environment (no gtk2dialog)
			button_colorsel='
			<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Legacy color selector')"' ">
				<input file>'$APPDIR'/icons/colorbutton.svg</input><height>30</height><width>30</width>
				<variable>warna2</variable>
				<action>pemilih_warna &</action>
				<action>exit:quit_now</action>
			</button>'
		fi
	else # GTK2 environment
		button_colorsel2='<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>'
	fi

# check availability of Adwaita icon theme
[ -f /usr/share/icons/Adwaita/512x512/places/folder.png ] && adwaita='<item>Adwaita</item>' || adwaita=''

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

gettext "<b><span size='"'x-large'"'>JWMdesk Theme Manager</span></b>

<b>Purpose</b>
The JWMdesk Theme Manager provides a simple graphical interface for managing theme colors of the JWM desktop. Based on the theme color changer (jcc) of Recobayu, this application supports the modern XML syntax implemented in JWM >= 2.3.0 but does not support theming in earlier (legacy) versions of JWM, in which case JWMdesk will hide this option.

The theme manager defaults to a small window which supports essential theming functions. However, if you prefer, a toggle button (upper left corner) will expand the window for quick access to an array of favorite colors. From either window you can quickly change the current JWM theme color for the desktop menu, tray, and window borders.

Although the theme manager applies gradations of the selected JWM color for a uniform color scheme, you can customize the appearance by enabling the 'Dark colors' option which applies the selected dark color to the menu, tray, and inactive window borders. The default dark color is gray20 (#333333) but you can apply any JWM color to match the current desktop theme.

<b>Extra Functions</b>
Additionally, the graphical interface of the theme manager provides options for more robust desktop theming. While creating a new JWM theme you can enable checkbox options that will (1) create a new desktop background and (2) create a new RoxFiler folder, both of which will match the color scheme of the new JWM theme. To further customize the desktop theme, there are separate color selectors for the background and folder options.

<b>Background Option</b>
The background option provides a user-editable entry for creating the background label (banner) with a choice of text formats (no label, flat, outline, shadow and embossed) in multiple sizes (48-152 px). The label option defaults to the name of the current Puppy distro but you can enter any text to create a personalized banner. A toggle button provides a convenient portal to label and font options.

If the background option is enabled and a screen compositor is active (such as Compton or Picom), the theme manager will automatically apply partial transparency (85% opacity) to the JWM tray. However, even if a compositor is not present, the transparent tray option applies the selected color to both background and tray, simulating 100% panel transparency.

The background option defaults to a solid-color wallpaper but you can enable the gradient option which applies a linear or radial gradient based on the current JWM theme color or any user-selected custom color. Keep in mind, as with any gradient wallpaper, those who use an application to adjust the screen color temperatute may observe visible gradient lines at lower screen brightness and temperature settings.

Selecting the background gradient option will automatically disable the transparent tray option since pseudo-transparency of the panel requires identical colors for the background and tray. Conversely, selecting the transparent tray option will automatically disable the background gradient option.

Of course, for those who prefer a choice of standard background images, there is a button to quickly launch a conventional wallpaper setter. While in use, this action will disable the other background widgets of the theme manager since they function only to customize solid colors. Simply enable those background options again when you switch back to a solid-color background.

For granular control of the background option please go to Preferences and choose the preferred wallpaper selector, background text color, and background gradient properties.

<b>Folder Option</b>
The folder option provides a selection of RoxFiler folder styles which may be assigned the color of your choice. The color of the Desktop style is defined by the current desktop icon theme. Please be aware, after the current folder color is changed RoxFiler may require a refresh before the new folder color is visible. You can do this easily in RoxFiler by pressing the F5 key or by clicking the Rescan button in the top menu bar. To restore the original color of the folder, simply uncheck the folder checkbox and click the Apply button (lower left)." > /tmp/jcc_help

help_dialog()
{
export Help='
<window default-height="450" default-width="650" title="'$(gettext 'Help')'" icon-name="jwm_themes" 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/jcc_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 help_dialog

help_gui_width=480
GEO_HELP=+$((($MX/2)-$((($help_gui_width+20)/2))))+$((($MY/2)-360))
[ ! "$GEO_HELP" ] && GEO_HELP=+50+50
export GEO_HELP

theme_manager_help()
{
export THEME_MANAGER_HELP="
<window default-width=\"425\" title=\"Theme Manager\" icon-name=\"jwm_themes\" resizable=\"false\">
	<vbox margin=\"10\" width-request=\"425\">
		<pixmap><input file>$APPDIR/icons/jwm_themes.svg</input><height>72</height><width>72</width></pixmap>
		<text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>JWMdesk</span></b>\"</label></text>
		<text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Theme Manager</span>  $VERSION</b>\"</label></text>
		<text use-markup=\"true\"><label>\"<b>$(gettext 'Manage desktop theming')</b>\"</label></text>
		<text><label>\"Roger D. Grider (C) 2023 GPL3\"</label></text>
		<pixmap><input file>/usr/local/jwmdesk/icons/blank1.png</input></pixmap>
		<pixmap><input file>/usr/local/jwmdesk/icons/blank1.png</input></pixmap>
		<hbox space-expand=\"false\" space-fill=\"true\" homogeneous=\"true\">
			<button tooltip-text=\" Online JWMdesk forum \">
				<label>\"$(gettext 'Forum')\"</label>
				<action>defaulthtmlviewer https:\/\/forum.puppylinux.com\/viewtopic.php?p=32274#p32274 &</action>
			</button>
			<button>
				<label>\"$(gettext 'Help')\"</label>
				<action>help_dialog &</action>
			</button>
			<button tooltip-text=\" http://www.gnu.org/licenses \">
				<label>\"$(gettext 'License')\"</label>
				<action>defaulthtmlviewer http:\/\/www.gnu.org\/licenses\/ &</action>
			</button>
		</hbox>
	</vbox>
</window>"
$GTKDIALOG -p THEME_MANAGER_HELP --geometry="$GEO_HELP"
unset THEME_MANAGER_HELP
}
export -f theme_manager_help

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

export tema_jwm_gui='
<window title="'"$(gettext 'JWMdesk Theme Manager')"'" resizable="false" icon-name="jwm_themes">
<vbox width-request="'"$gui_width"'">
	<hbox homogeneous="true">
		<text use-markup="true" homogeneous="true" space-expand="true" space-fill="true" tooltip-text=" '"$(gettext 'The JWM theme defines all colors for the 
 desktop menu, tray and window borders.')"' "><label>"'"<b><span size='"'medium'"'>$(gettext 'JWM Theme')</span></b>"'"</label></text>
	</hbox>
	<hbox margin="2" space-expand="true" space-fill="true">
		<togglebutton space-expand="false" space-fill="false" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Toggle color buttons')"' ">
			<input file>'$APPDIR'/icons/jwm_themes.svg</input><height>30</height><width>30</width>
			<variable>colorbuttons</variable>
			<default>'$colorbuttons'</default>
			<action>if true show:cb_toggle</action>
			<action>if true echo true > '$APPDIR'/.jcc/colorbuttons</action>
			<action>if false hide:cb_toggle</action>
			<action>if false echo false > '$APPDIR'/.jcc/colorbuttons</action>
		</togglebutton>
		<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>
		<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>
		<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
		'$button_colorsel2'
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Color tool')"' ">
			<input file>'$APPDIR'/icons/color-picker.svg</input><height>30</height><width>30</width>
			<action>'$APPDIR'/xcolor &</action>
		</button>
		'$button_colorsel'
		<colorbutton space-expand="false" space-fill="false" height-request="40" width-request="225" title="JWM theme color" tooltip-text=" '"$(gettext 'Default color selector')"' ">
			<variable>warna</variable>
			<input file>'$APPDIR'/.jcc/warnasekarang</input>
			<action>echo "$warna" > '$APPDIR'/.jcc/folder-color</action>
			<action>echo > '$APPDIR'/.jcc/bg-color</action>
			<action>echo > '$APPDIR'/.jcc/bg-color-bak</action>
			<action>ganti_tema_umum "$warna"</action>
			<action>refresh:warna2</action>
			<action>refresh:folder_color</action>
			<action>refresh:bg_color</action>
		</colorbutton>
		'$button_themebuilder'
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Legacy JWM theme switcher')"' ">
			<input file>'$APPDIR'/icons/theme_switcher.svg</input><height>25</height><width>25</width>
			<action>'$APPDIR'/theme_switcher &</action>
		</button>
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Legacy JWM title bar manager')"' ">
			<input file>'$APPDIR'/icons/close.svg</input><height>33</height><width>33</width>
			<action>'$APPDIR'/window_titlebar &</action>
		</button>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
		<text space-expand="false" space-fill="false" height-request="40" width-request="40"><label>" "</label></text>
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'Help')"' ">
			<input file>'$APPDIR'/icons/help.svg</input><height>25</height><width>25</width>
			<action>theme_manager_help &</action>
		</button>
		<button space-expand="false" space-fill="false" relief="1" height-request="40" width-request="40" tooltip-text=" '"$(gettext 'View current desktop themes')"' ">
			<input file>'$APPDIR'/icons/view.svg</input><height>30</height><width>30</width>
			<action>'$APPDIR'/current_themes &</action>
		</button>
	</hbox>

	<pixmap><input file>'$APPDIR'/icons/blank1.png</input></pixmap>

	<hbox homogeneous="true" space-expand="true" space-fill="true">
		<colorbutton sensitive="'"$ss0"'" space-expand="false" space-fill="false" width-request="120" title="JWM theme dark color" tooltip-text=" '"$(gettext 'Dark color selector')"' ">
			<variable>dark_color</variable>
			<input file>'$APPDIR'/.jcc/dark-color</input>
			<action>echo "$dark_color" > '$APPDIR'/.jcc/dark-color</action>
			<action>echo "$dark_color" > '$APPDIR'/.jcc/dark-color-bak</action>
		</colorbutton>
	</hbox>

	<hbox homogeneous="true">
	<vbox space-expand="false" space-fill="false">
		<checkbox tooltip-text=" '"$(gettext 'Enable flat jwm colors or uncheck for gradient style')"' ">
			<label>"'"$(gettext 'Flat colors')"'"</label>
			<variable>flat_style</variable>
			<input file>'$APPDIR'/.jcc/flat-style</input>
			<action>if true echo true > '$APPDIR'/.jcc/flat-style</action>
			<action>if false echo false > '$APPDIR'/.jcc/flat-style</action>
		</checkbox>
	</vbox>
	<vbox space-expand="false" space-fill="false">
		<checkbox tooltip-text=" '"$(gettext 'Enable dark background colors for the menu, tray') 
 $(gettext 'and inactive window borders. (Default: #333333)')"' ">
			<label>"'"$(gettext 'Dark colors')"'"</label>
			<variable>window_only</variable>
			<input file>'$APPDIR'/.jcc/window-only</input>
			<action>if true cat '$APPDIR'/.jcc/dark-color-bak > '$APPDIR'/.jcc/dark-color</action>
			<action>if true refresh:dark_color</action>
			<action>if true enable:dark_color</action>
			<action>if true echo true > '$APPDIR'/.jcc/window-only</action>
			<action>if false echo "#EBEBEB" > '$APPDIR'/.jcc/dark-color</action>
			<action>if false refresh:dark_color</action>
			<action>if false disable:dark_color</action>
			<action>if false echo false > '$APPDIR'/.jcc/window-only</action>
		</checkbox>
	</vbox>
	<vbox space-expand="false" space-fill="false">
		<checkbox sensitive="'"$ss00"'" tooltip-text=" '"$(gettext 'Enable tray transparency or uncheck for solid color')"' ">
			<label>"'"$(gettext 'Tray transparency')"'"</label>
			<variable>transparent_tray</variable>
			<input file>'$APPDIR'/.jcc/transparent-tray</input>
			<action>if true echo true > '$APPDIR'/.jcc/bg-solid-color</action>
			<action>if true refresh:bg_solid_color</action>
			<action>if true echo true > '$APPDIR'/.jcc/transparent-tray</action>
			<action>if true echo false > '$APPDIR'/.jcc/bg-gradient</action>
			<action>if true refresh:bg_gradient</action>
			<action>if false echo false > '$APPDIR'/.jcc/transparent-tray</action>
		</checkbox>
	</vbox>
	</hbox>

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

	<vbox visible="'${colorbuttons}'">
		'$(warna_terbaru)'
		'$(warna_kesukaan)'
		<variable>cb_toggle</variable>
	</vbox>

	<hbox margin="2" space-expand="true" space-fill="true">
	<vbox space-expand="true" space-fill="true">
	<hbox homogeneous="true">
		<text><label>"'"$(gettext 'Apply')"'"</label></text>
	</hbox>
	<hbox>
		<button height-request="35" width-request="60" space-expand="true" space-fill="true" tooltip-text=" '"$(gettext 'Apply selected desktop themes')"' ">
			<variable>bg_update</variable>
			<input file>'$APPDIR'/icons/update.svg</input><height>24</height><width>24</width>
			<action>perbarui_latar_belakang &</action>
		</button>
	</hbox>
	</vbox>

	<text space-expand="true" space-fill="true"><label>" "</label></text>
	<vseparator space-expand="false" space-fill="false"></vseparator>
	<text space-expand="true" space-fill="true"><label>" "</label></text>

	<vbox space-expand="true" space-fill="true">
	<hbox space-expand="true" space-fill="true">
		<text xalign="0" use-markup="true"><label>"'"<b><span size='"'medium'"'>$(gettext 'Background')</span></b>"'"</label></text>
		<checkbox space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Create background with solid or gradient colors') 
 $(gettext 'or uncheck to continue the current background.')"' ">
			<label>""</label>
			<variable>bg</variable>
			<input file>'$APPDIR'/.jcc/bg</input>
			<action>if true echo true > '$APPDIR'/.jcc/bg</action>
			<action>if true perbarui_pemilih_warna</action>
			<action>if true refresh:bg_color</action>
			<action>if true enable:bg_label</action>
			<action>if true enable:bg_label_text</action>
			<action>if true enable:bg_color</action>
			<action>if true enable:bg_label_deco</action>
			<action>if true enable:font_name</action>
			<action>if true enable:font_size</action>
			<action>if true enable:font_style</action>
			<action>if true enable:transparent_tray</action>
			<action>if true echo true > '$APPDIR'/.jcc/bg-solid-color</action>
			<action>if true refresh:bg_solid_color</action>
			<action>if true enable:bg_solid_color</action>
			<action>if true enable:bg_gradient</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg-solid-color</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg-gradient</action>
			<action>if false clear:bg_solid_color</action>
			<action>if false disable:bg_solid_color</action>
			<action>if false clear:bg_gradient</action>
			<action>if false disable:bg_gradient</action>
			<action>if false echo "#EBEBEB" > '$APPDIR'/.jcc/bg-color-bak</action>
			<action>if false refresh:bg_color</action>
			<action>if false disable:bg_label</action>
			<action>if false disable:bg_label_text</action>
			<action>if false disable:bg_color</action>
			<action>if false disable:bg_label_deco</action>
			<action>if false disable:font_name</action>
			<action>if false disable:font_size</action>
			<action>if false disable:font_style</action>
			<action>if false echo false > '$APPDIR'/.jcc/transparent-tray</action>
			<action>if false refresh:transparent_tray</action>
			<action>if false disable:transparent_tray</action>
		</checkbox>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
		<checkbox sensitive="'"$ss1"'" space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Apply solid color to background')"' ">
			<label>"'"$(gettext 'Solid')"'"</label>
			<variable>bg_solid_color</variable>
			<input file>'$APPDIR'/.jcc/bg-solid-color</input>
			<action>if true echo true > '$APPDIR'/.jcc/bg-solid-color</action>
			<action>if true echo false > '$APPDIR'/.jcc/bg-gradient</action>
			<action>if true refresh:bg_gradient</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg-solid-color</action>
		</checkbox>
		<checkbox sensitive="'"$ss1"'" space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Apply gradient colors to background')"' ">
			<label>"'"$(gettext 'Gradient')"'"</label>
			<variable>bg_gradient</variable>
			<input file>'$APPDIR'/.jcc/bg-gradient</input>
			<action>if true echo true > '$APPDIR'/.jcc/bg-gradient</action>
			<action>if true echo false > '$APPDIR'/.jcc/bg-solid-color</action>
			<action>if true refresh:bg_solid_color</action>
			<action>if true echo false > '$APPDIR'/.jcc/transparent-tray</action>
			<action>if true refresh:transparent_tray</action>
			<action>if true echo "#EBEBEB" > '$APPDIR'/.jcc/bg-color-bak</action>
			<action>if true refresh:bg_color</action>
			<action>if true disable:bg_color</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg-gradient</action>
			<action>if false perbarui_pemilih_warna</action>
			<action>if false refresh:bg_color</action>
			<action>if false enable:bg_color</action>
		</checkbox>
	</hbox>
	<hbox>
		<togglebutton sensitive="'"$ss1"'" height-request="35" width-request="35" space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Toggle label options')"' ">
			<input file>'$APPDIR'/icons/font.svg</input><height>22</height><width>22</width>
			<variable>bg_label</variable>
			<default>'$bg_label'</default>
			<action>if true show:font_toggle</action>
			<action>if true echo true > '$APPDIR'/.jcc/bg-label</action>
			<action>if false hide:font_toggle</action>
			<action>if false echo false > '$APPDIR'/.jcc/bg-label</action>
		</togglebutton>
		<comboboxentry sensitive="'"$ss2"'" wrap-width="1" width-request="'"$cbox1_width"'" space-expand="true" space-fill="true" tooltip-text=" '"$(gettext 'Text of background label')"' ">
			<variable>bg_label_text</variable>
			<default>'$bg_label_text'</default>
			<item>distro</item>
			<item>distro + version</item>
			<action>echo "$bg_label_text" > '$APPDIR'/.jcc/bg-label-text</action>
		</comboboxentry>
		<colorbutton sensitive="'"$ss3"'" height-request="35" width-request="35" space-expand="false" space-fill="false" title="Background color" tooltip-text=" Background color selector ">
			<input file>'$APPDIR'/.jcc/bg-color-bak</input>
			<variable>bg_color</variable>
			<action>echo $bg_color > '$APPDIR'/.jcc/bg-color</action>
			<action>echo $bg_color > '$APPDIR'/.jcc/bg-color-bak</action>
		</colorbutton>
		<button height-request="35" width-request="35" tooltip-text=" '"$(gettext 'Background wallpaper selector')"' ">
			<input file>'$APPDIR'/icons/wallpaper.svg</input><height>24</height><width>24</width>
			<action>echo false > '$APPDIR'/.jcc/transparent-tray</action>
			<action>echo false > '$APPDIR'/.jcc/bg</action>
			<action>refresh:transparent_tray</action>
			<action>refresh:bg</action>
			<action>aplikasi_wallpaper &</action>
		</button>
		<button height-request="35" width-request="35" tooltip-text=" '"$(gettext 'Background preferences')"' ">
			<input file>'$APPDIR'/icons/preferences.svg</input><height>21</height><width>21</width>
			<action>. '$APPDIR'/jcc_preferences &</action>
		</button>
	</hbox>
	</vbox>

	<text space-expand="true" space-fill="true"><label>" "</label></text>
	<vseparator space-expand="false" space-fill="false"></vseparator>
	<text space-expand="true" space-fill="true"><label>" "</label></text>

	<vbox sensitive="'$FOLDER_STATE'" space-expand="true" space-fill="true">
	<hbox space-expand="true" space-fill="true">
		<text xalign="0" use-markup="true"><label>"'"<b><span size='"'medium'"'>$(gettext 'Folder')</span></b>"'"</label></text>
		<checkbox space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Create folder with the selected color') 
 $(gettext 'or uncheck to use the original folder.')"' ">
			<label>""</label>
			<variable>folder</variable>
			<input file>'$APPDIR'/.jcc/folder</input>
			<action>if true echo true > '$APPDIR'/.jcc/folder</action>
			<action>if true echo "$warna" > '$APPDIR'/.jcc/folder-color</action>
			<action>if true refresh:folder_color</action>
			<action>if true enable:folder_color</action>
			<action>if true enable:folder_style</action>
			<action>if false echo false > '$APPDIR'/.jcc/folder</action>
			<action>if false echo "#EBEBEB" > '$APPDIR'/.jcc/folder-color</action>
			<action>if false refresh:folder_color</action>
			<action>if false disable:folder_color</action>
			<action>if false disable:folder_style</action>
		</checkbox>
		<text space-expand="false" space-fill="false"><label>"   "</label></text>
		<checkbox space-expand="false" space-fill="false" tooltip-text=" '"$(gettext 'Apply selected color to folders only and ignore') 
 $(gettext 'the current JWM and background color options.')"' ">
			<label>"'"$(gettext 'Only')"'"</label>
			<variable>folder_only</variable>
			<input file>'$APPDIR'/.jcc/folder-only</input>
			<action>if true echo true > '$APPDIR'/.jcc/folder-only</action>
			<action>if false echo false > '$APPDIR'/.jcc/folder-only</action>
		</checkbox>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
	</hbox>
	<hbox>
		<comboboxtext sensitive="'"$ss5"'" wrap-width="1" width-request="'"$cbox2_width"'" space-expand="true" space-fill="true" tooltip-text=" '"$(gettext 'Folder style')"' ">
			<variable>folder_style</variable>
			<default>'$folder_style'</default>
			'$adwaita'
			<item>Accent</item>
			<item>Buntu</item>
			<item>Buntu Light</item>
			<item>Desktop</item>
			<item>Legacy</item>
			<item>Modern</item>
			<item>PMaterial</item>
			<item>Puppy Flat</item>
			<item>Puppy Standard</item>
			<action>echo "$folder_style" > '$APPDIR'/.jcc/folder-style</action>
		</comboboxtext>
		<colorbutton sensitive="'"$ss5"'" height-request="35" width-request="35" space-expand="false" space-fill="false" title="Folder color" tooltip-text=" Folder color selector ">
			<input file>'$APPDIR'/.jcc/folder-color</input>
			<variable>folder_color</variable>
			<action>echo $folder_color > '$APPDIR'/.jcc/folder-color</action>
			<action>ganti_warna_folder</action>
		</colorbutton>
	</hbox>
	</vbox>
	</hbox>

	<hbox visible="'${bg_label}'" margin="2" space-expand="true" space-fill="true">
	<vbox space-expand="true" space-fill="true">
	<hbox homogeneous="true">
		<text xalign="0"><label>"'"$(gettext 'Label style')"'"</label></text>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
	</hbox>
	<hbox>
		<comboboxtext sensitive="'"$ss4"'" wrap-width="1" width-request="'"$cbox3_width"'" space-expand="true" space-fill="true" tooltip-text=" '"$(gettext 'Decoration of background label')"' ">
			<variable>bg_label_deco</variable>
			<default>'$bg_label_deco'</default>
			<item>no label</item>
			<item>flat</item>
			<item>outline</item>
			<item>shadow</item>
			<item>emboss</item>
			<action>echo "$bg_label_deco" > '$APPDIR'/.jcc/bg-label-deco</action>
		</comboboxtext>
	</hbox>
	</vbox>

	<vbox space-expand="true" space-fill="true">
	<hbox homogeneous="true">
		<text xalign="0"><label>"'"$(gettext 'Font name')"'"</label></text>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
	</hbox>
	<hbox>
		<comboboxtext sensitive="'"$ss4"'" wrap-width="1" width-request="'"$cbox4_width"'" space-expand="true" space-fill="true">
			<variable>font_name</variable>
			<default>'$font_name'</default>
			'$font_name_items'
			<action>echo "$font_name" > '$APPDIR'/.jcc/font-name</action>
		</comboboxtext>
	</hbox>
	</vbox>

	<vbox space-expand="true" space-fill="true">
	<hbox homogeneous="true">
		<text xalign="0"><label>"'"$(gettext 'Font size')"'"</label></text>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
	</hbox>
	<hbox>
		<comboboxtext sensitive="'"$ss4"'" wrap-width="2" width-request="115" space-expand="true" space-fill="true">
			<variable>font_size</variable>
			<default>'$font_size'</default>
			<item>48</item>
			<item>104</item>
			<item>56</item>
			<item>112</item>
			<item>64</item>
			<item>120</item>
			<item>72</item>
			<item>128</item>
			<item>80</item>
			<item>136</item>
			<item>88</item>
			<item>144</item>
			<item>96</item>
			<item>152</item>
			<action>echo "$font_size" > '$APPDIR'/.jcc/font-size</action>
		</comboboxtext>
	</hbox>
	</vbox>

	<vbox space-expand="true" space-fill="true">
	<hbox homogeneous="true">
		<text xalign="0"><label>"'"$(gettext 'Font style')"'"</label></text>
		<text space-expand="true" space-fill="true"><label>" "</label></text>
	</hbox>
	<hbox>
		<comboboxtext sensitive="'"$ss4"'" wrap-width="1" width-request="115" space-expand="true" space-fill="true">
			<variable>font_style</variable>
			<default>'$font_style'</default>
			<item>normal</item>
			<item>italic</item>
			<action>echo "$font_style" > '$APPDIR'/.jcc/font-style</action>
		</comboboxtext>
	</hbox>
	</vbox>
	<variable>font_toggle</variable>
	</hbox>

</vbox>
<action signal="show">echo 100 > /tmp/thememanager-splash</action>
<action signal="key-press-event" condition="command_is_true([ $KEY_SYM = Escape ] && echo true )">exit:EXIT</action>
</window>'

$GTKDIALOG -p tema_jwm_gui --geometry="$GEO" --styles=$TMPDIR/gtkrc.css 2>/dev/null

unset tema_jwm_gui

kill $JCC 2>/dev/null

exit 0
