#!/bin/bash
#PupClockset 2.3.1
#Copyright GPL3, http://www.gnu.org/licenses/
#Roger Grider (radky)
#20130720 internationalized (vicmz)

export TEXTDOMAIN=pupclockset
export OUTPUT_CHARSET=UTF-8

WORKDIR="/usr/local/PupClockset"

#define gtkdialog
if [ "`which gtkdialog4`" ]; then
 GTKDIALOG=gtkdialog4
elif [ "`which gtkdialog3`" ]; then
 GTKDIALOG=gtkdialog3
else
 GTKDIALOG=gtkdialog
fi

#auto-adjust header text color for light or dark GTK themes
if [ "`grep 'Stardust_dark' $HOME/.gtkrc-2.0 2>/dev/null`" ]; then #gold text for unique Stardust dark-grey-orange themes
  COLOR=#D7B740
else #light-blue text for common dark themes, otherwise medium blue
  [ "`grep -Ei 'black|dark|night' $HOME/.gtkrc-2.0 2>/dev/null`" ] && COLOR=#84aad9 || COLOR=#3272C0
fi
export COLOR

#define current window manager
if [ -f "$HOME/Choices/windowmanager" ]; then
  CURRWM=`cat "$HOME/Choices/windowmanager"` #TazOC LHP
else
  CURRWM=`cat /etc/windowmanager`
fi
. /etc/DISTRO_SPECS
if [ "$DISTRO_NAME" = "Fatdog64" ]; then
 if [ -s "$FATDOG_STATE_DIR/windowmanager" ]; then
  CURRWM=`cat "$FATDOG_STATE_DIR/windowmanager"`
 elif [ "`pidof openbox`" ]; then
  CURRWM="openbox-session"
 elif [ "`pidof jwm`" ]; then
  CURRWM="jwm"
 elif [ "`pidof icewm`" ]; then
  CURRWM="icewm"
 elif [ "`pidof xfwm4`" ]; then
  CURRWM="xfwm4"
 fi
 echo "$CURRWM" > /etc/windowmanager
fi

#define general font parameters
if [ "$CURRWM" = "startxfce4" -o "$CURRWM" = "xfce4-session" -o "$CURRWM" = "xfwm4" ]; then
	XFWM4="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml"
	XFDPI=$(cat $XFWM4 | grep '"DPI' | awk '{print $4}' | cut -d "=" -f2 | sed -e 's/\"//g' -e 's/\/>//g')
	[ "$XFDPI" = "" -o "$XFDPI" = "-1" ] && XFDPI="96"
	FONT_SIZE=$(grep '"FontName' $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml | sed -e s'/"\/>//g' | awk -F' ' '{print $NF}')
else
	[ ! -f "$HOME/.gtkrc-2.0.bak" ] && cp -f $HOME/.gtkrc-2.0 $HOME/.gtkrc-2.0.bak
	if [ ! "`grep font_name $HOME/.gtkrc-2.0`" ]; then
	 if [ "`which hackfontsize`" ]; then
	  sed -i '4i\style "user-font" {\n	font_name = "Sans 10"\n}\n' $HOME/.gtkrc-2.0
	 else
	  sed -i '4i\style "user-font" {\n	font_name = "Sans 12"\n}\n' $HOME/.gtkrc-2.0
	 fi
	fi
	CURRDPI=`grep "^Xft\\.dpi:" $HOME/.Xresources 2>/dev/null | tr '\t' ' ' | tr -s ' ' | cut -f 2 -d ' '`
	[ "$CURRDPI" = "" ] && CURRDPI="96"
	FONT_SIZE=$(grep font_name $HOME/.gtkrc-2.0 2>/dev/null | sed 's/\"//g' | awk '{ print $NF }')
fi
if [ "$FONT_SIZE" = "10" ]; then
 FRAMEFONT_SIZE="8"
else
 FONT_SIZE="11"
 FRAMEFONT_SIZE="10"
fi
echo "style \"specialsize\"
{
  font_name=\"Sans $FONT_SIZE\"
}
widget \"*\" style \"specialsize\"
class \"*\" style \"specialsize\"

style \"specialframe\"
{
  font_name=\"Sans bold $FRAMEFONT_SIZE\"
#  fg[NORMAL]=\"grey40\"
}
widget \"*.GtkFrame.GtkLabel\" style \"specialframe\"
class \"*.GtkFrame.GtkLabel\" style \"specialframe\"" > "$WORKDIR/gtkrc_special"

export GTK2_RC_FILES="$WORKDIR/gtkrc_special:${HOME}/.gtkrc-2.0"

#define button width-request for GUI tray and combobox width-request for Options tab
if [ "$CURRWM" = "startxfce4" -o "$CURRWM" = "xfce4-session" -o "$CURRWM" = "xfwm4" ]; then
 if [ "$FONT_SIZE" = "10" ]; then
  if [[ $XFDPI -ge 112 ]] && [[ $XFDPI -lt 119 ]]; then TRAY_BUTTON_WIDTH=$"75" COMBOBOX_WIDTH=$"142" VBOX_WIDTH=$"305"
  elif [[ $XFDPI -ge 105 ]] && [[ $XFDPI -lt 112 ]]; then TRAY_BUTTON_WIDTH=$"71" COMBOBOX_WIDTH=$"132" VBOX_WIDTH=$"285"
  elif [[ $XFDPI -ge 98 ]] && [[ $XFDPI -lt 105 ]]; then TRAY_BUTTON_WIDTH=$"67" COMBOBOX_WIDTH=$"126" VBOX_WIDTH=$"273"
  elif [[ $XFDPI -ge 70 ]] && [[ $XFDPI -lt 98 ]]; then TRAY_BUTTON_WIDTH=$"64" COMBOBOX_WIDTH=$"121" VBOX_WIDTH=$"263"
  else TRAY_BUTTON_WIDTH=$"67" COMBOBOX_WIDTH=$"126" VBOX_WIDTH=$"273"
  fi
 else
  if [[ $XFDPI -ge 115 ]] && [[ $XFDPI -lt 128 ]]; then TRAY_BUTTON_WIDTH=$"84" COMBOBOX_WIDTH=$"170" VBOX_WIDTH=$"363"
  elif [[ $XFDPI -ge 108 ]] && [[ $XFDPI -lt 115 ]]; then TRAY_BUTTON_WIDTH=$"78" COMBOBOX_WIDTH=$"155" VBOX_WIDTH=$"333"
  elif [[ $XFDPI -ge 70 ]] && [[ $XFDPI -lt 108 ]]; then TRAY_BUTTON_WIDTH=$"74" COMBOBOX_WIDTH=$"145" VBOX_WIDTH=$"313"
  else TRAY_BUTTON_WIDTH=$"74" COMBOBOX_WIDTH=$"145" VBOX_WIDTH=$"313"
  fi
 fi
elif [ "$FONT_SIZE" = "10" ]; then
 if  	[ $CURRDPI = "108" ]; then TRAY_BUTTON_WIDTH=$"66" COMBOBOX_WIDTH=$"140" VBOX_WIDTH=$"303"
 elif	[ $CURRDPI = "102" ]; then TRAY_BUTTON_WIDTH=$"64" COMBOBOX_WIDTH=$"129" VBOX_WIDTH=$"281"
 elif	[ $CURRDPI = "96" ]; then TRAY_BUTTON_WIDTH=$"62" COMBOBOX_WIDTH=$"120" VBOX_WIDTH=$"263"
 elif	[ $CURRDPI = "90" ]; then TRAY_BUTTON_WIDTH=$"60" COMBOBOX_WIDTH=$"117" VBOX_WIDTH=$"256"
 elif	[ $CURRDPI = "84" ]; then TRAY_BUTTON_WIDTH=$"58" COMBOBOX_WIDTH=$"114" VBOX_WIDTH=$"252"
 elif	[ $CURRDPI = "78" ]; then TRAY_BUTTON_WIDTH=$"57" COMBOBOX_WIDTH=$"113" VBOX_WIDTH=$"248"
 elif	[ $CURRDPI = "72" ]; then TRAY_BUTTON_WIDTH=$"54" COMBOBOX_WIDTH=$"110" VBOX_WIDTH=$"243"
 fi
else
 if  	[ $CURRDPI = "108" ]; then TRAY_BUTTON_WIDTH=$"74" COMBOBOX_WIDTH=$"170" VBOX_WIDTH=$"364"
 elif	[ $CURRDPI = "102" ]; then TRAY_BUTTON_WIDTH=$"70" COMBOBOX_WIDTH=$"161" VBOX_WIDTH=$"345"
 elif	[ $CURRDPI = "96" ]; then TRAY_BUTTON_WIDTH=$"68" COMBOBOX_WIDTH=$"147" VBOX_WIDTH=$"316"
 elif	[ $CURRDPI = "90" ]; then TRAY_BUTTON_WIDTH=$"66" COMBOBOX_WIDTH=$"140" VBOX_WIDTH=$"303"
 elif	[ $CURRDPI = "84" ]; then TRAY_BUTTON_WIDTH=$"64" COMBOBOX_WIDTH=$"129" VBOX_WIDTH=$"281"
 elif	[ $CURRDPI = "78" ]; then TRAY_BUTTON_WIDTH=$"62" COMBOBOX_WIDTH=$"120" VBOX_WIDTH=$"263"
 elif	[ $CURRDPI = "72" ]; then TRAY_BUTTON_WIDTH=$"60" COMBOBOX_WIDTH=$"117" VBOX_WIDTH=$"256"
 fi
fi

#define title-bar icon
ln -snf $WORKDIR/icons/clockformat48.png /usr/share/icons/hicolor/48x48/apps && gtk-update-icon-cache -f -i /usr/share/icons/hicolor 2>/dev/null

#define unsupported panel clocks
[ "`echo "$CURRWM" | grep -i mate`" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset does not \n support the Mate clock.') " 0 0 && exit 0
[ "`echo "$CURRWM" | grep -i cinnamon`" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset does not \n support the Cinnamon clock.') " 0 0 && exit 0
[ "$CURRWM" = "startkde" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset does not \n support the Kde clock.') " 0 0 && exit 0
[ "`pidof enlightenment`" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset does not support \n the Enlightenment desktop clock.') " 0 0 && exit 0
#[ "`pidof lxpanelx`" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset does not support \n the desktop clock of Lxpanelx.') " 0 0 && exit 0
#[ "`which ptray`" ] && Xdialog --title Alert --beep --msgbox " $(gettext 'PupClockset is not recommended \n for DuDE (Stardust environment).') " 0 0 && exit 0

#define default configuration path for popular panels and window managers
[ ! -d $HOME/.icewm/ ] && mkdir -p $HOME/.icewm/ ; [ ! -f $HOME/.icewm/preferences ] && echo > $HOME/.icewm/preferences ; [ ! -f $HOME/.icewm/prefoverride ] && echo > $HOME/.icewm/prefoverride
FBPANEL="$HOME/.config/fbpanel/default"
FLUXBOX="$HOME/.fluxbox/init"
FLUXBOX2="$HOME/.fluxbox/overlay"
ICEWM="$HOME/.icewm/preferences"
ICEWM2="$HOME/.icewm/prefoverride"
JWM="$HOME/.jwmrc-tray"

#define default configuration path for LXPanel
if
 [ "$DISTRO_NAME" = "Lighthouse64" ]; then
 LXPANEL="$HOME/.config/lxpanel/default/panels/panel"
elif
 [ "$CURRWM" = "openbox-lxde" -o "$CURRWM" = "startlxde" ]; then
 LXPANEL="$HOME/.config/lxpanel/LXDE/panels/panel"
elif
 [ "`pidof lxpanel`" -o "`pidof lxpanel.bin`" ]; then
 LXPANEL=`find $HOME/.config/lxpanel/ -name 'panel'`
fi

#if no PupClockset configuration file, then build file
[ ! -s $WORKDIR/clock-variables.rc ] && echo -e -n 'CLOCKVAR1="true"\nCLOCKVAR2="false"\nCLOCKVAR3="false"\nCLOCKVAR4="false"\nCLOCKVAR5="false"\nCLOCKVAR6="false"\nCLOCKVAR7="false"\nCLOCKVAR8="false"\nCLOCKVAR9="true"\nCLOCKVAR10="false"\nCLOCKVAR11="false"\nCLOCKVAR12="false"\nCLOCKVAR13="false"\nCLOCKVAR14="false"\nCLOCKVAR15="false"\nCLOCKVAR16="false"\nCLOCKVAR17="true"\nCLOCKVAR18="false"\nCLOCKVAR19="false"\nCLOCKVAR20="false"\nCLOCKVAR21="false"\nCLOCKVAR22="false"\nCLOCKVAR23="false"\nCLOCKVAR24="false"\nCLOCKVAR25="true"\nCLOCKVAR26="false"\nCLOCKVAR27="false"\nCLOCKVAR28="false"\nCLOCKVAR29="false"\nCLOCKVAR30="false"\nCLOCKVAR31="false"\nCLOCKVAR32="false"\nCLOCKVAR33="true"\nCLOCKVAR34="false"\nCLOCKVAR35="false"\nCLOCKVAR36="false"\nCLOCKVAR37="false"\nCLOCKVAR38="false"\nCLOCKVAR39="false"\nCLOCKVAR40="false"\nCLOCKVAR41="true"\nCLOCKVAR42="false"\nCLOCKVAR43="false"\nCLOCKVAR44="false"\nCLOCKVAR45="false"\nCLOCKVAR46="false"\nCLOCKVAR47="false"\nCLOCKVAR48="false"\n' > $WORKDIR/clock-variables.rc
. $WORKDIR/clock-variables.rc

#if no window manager configuration backup files, then create files
[ "`pidof fbpanel`" ] && [ ! -f $FBPANEL-bak ] && cp $FBPANEL $FBPANEL-bak
[ "`pidof fbpanel`" ] && [ ! -f /usr/sbin/pfbpanel-bak ] && cp /usr/sbin/pfbpanel /usr/sbin/pfbpanel-bak
[ "`pidof fluxbox`" ] && [ ! -f $FLUXBOX-bak ] && cp $FLUXBOX $FLUXBOX-bak
[ "`pidof fluxbox`" ] && [ ! -f $FLUXBOX2-bak ] && cp $FLUXBOX2 $FLUXBOX2-bak
[ "`pidof icewm`" -o "`pidof icewm-session`" ] && [ ! -f $ICEWM-bak ] && cp $ICEWM $ICEWM-bak
[ "`pidof icewm`" -o "`pidof icewm-session`" ] && [ ! -f $ICEWM2-bak ] && cp $ICEWM2 $ICEWM2-bak
[ "`pidof jwm`" ] && [ ! -f $JWM-bak ] && cp $JWM $JWM-bak

#if no LXPanel configuration backup file, then create file in the appropriate subdirectory
if [ "`pidof lxpanel`" -o "`pidof lxpanel.bin`" ]; then
 [ ! -d $HOME/.config/lxpanel/default/panels/ ] && mkdir -p $HOME/.config/lxpanel/default/panels/
 [ ! -f $HOME/.config/lxpanel/default/panels/panel ] && cp -f /usr/share/lxpanel/profile/default/panels/panel $HOME/.config/lxpanel/default/panels/
 [ "$LXPANEL" = "" ] && LXPANEL="$HOME/.config/lxpanel/default/panels/panel"
fi

if   [ "`pidof lxpanel.bin`" ]; then #support Fatdog64 and Lighthouse64
 LXP_DIR=`echo $LXPANEL | cut -d "/" -f 5  | sed 's/\///g'` #find parent directory of LXPanel profile
 if [ ! -f $HOME/.config/lxpanel/$LXP_DIR-panel.bak ]; then
  cp $LXPANEL $HOME/.config/lxpanel/$LXP_DIR-panel.bak #sync name of backup file with name of LXPanel profile
 fi
 if [ -f $HOME/.config/lxpanel/LXDE/panels/panel ] && [ ! -f $HOME/.config/lxpanel/LXDE-panel.bak ]; then #backup Lighthouse64 LXDE profile
  cp $HOME/.config/lxpanel/LXDE/panels/panel $HOME/.config/lxpanel/LXDE-panel.bak
 fi
elif [ "$CURRWM" = "openbox-lxde" -o "$CURRWM" = "startlxde" ]; then
 if [ -f $HOME/.config/lxpanel/LXDE/panels/panel ] && [ ! -f $HOME/.config/lxpanel/LXDE-panel.bak ]; then #backup standard LXDE profile
  cp $HOME/.config/lxpanel/LXDE/panels/panel $HOME/.config/lxpanel/LXDE-panel.bak
 fi
elif [ ! "`pidof lxpanel.bin`" ] && [ "`pidof lxpanel`" ]; then #backup standard LXPanel profile
 [ -f $LXPANEL-bak ] && rm -f $LXPANEL-bak
 [ ! -f $HOME/.config/lxpanel/lxpanel-panel.bak ] && cp $LXPANEL $HOME/.config/lxpanel/lxpanel-panel.bak
fi

#--- FBPANEL PARAMETERS --#

if [ "`pidof fbpanel`" ]; then

#define current font attributes for the clock of FBPanel
. $WORKDIR/func -current_fontname && . $WORKDIR/func -current_fontcolor

#define $FBPFONTNAME_ITEMS for font-name combobox
FBPFONTNAME_ITEMS=`cat /tmp/PCS-fontlist.txt`

#define $FBPFONTSIZE_ITEMS for font-size combobox
FBPFONTSIZE_ITEMS="<item>$(gettext 'xx-small')</item> <item>$(gettext 'x-small')</item> <item>$(gettext 'small')</item> <item>$(gettext 'medium')</item> <item>$(gettext 'large')</item> <item>$(gettext 'x-large')</item> <item>$(gettext 'xx-large')</item>"

#define $FBPFONTWEIGHT_ITEMS for font-weight combobox
FBPFONTWEIGHT_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'bold')</item>"

#define $FBPFONTSTYLE_ITEMS for font-style combobox
FBPFONTSTYLE_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'italic')</item>"

#define FBPanel minixcal option
 if [ "`which minixcal`" ]; then
	fbpXCAL="
    <frame Minixcal>
   <vbox>
     <checkbox tooltip-text=\" $(gettext 'By default, a mouse-click of the tray clock will open 
 PupClockset. If you prefer a small pop-up calendar, 
 select 'Yes' and click the Set button to use minixcal.') \">
      <label>$(gettext 'Yes')</label>
      <variable>FBP_XCAL</variable>
      <input>cat $WORKDIR/fbp_xcal 2>/dev/null</input>
      <action>if true echo true > $WORKDIR/fbp_xcal</action>
      <action>if false echo false > $WORKDIR/fbp_xcal</action>
     </checkbox>
   </vbox>
    </frame>"
 else
	fbpXCAL=""
 fi
fi

#--- FLUXBOX PARAMETERS --#

if [ "`pidof fluxbox`" ]; then

#define current font attributes for the clock of Fluxbox
. $WORKDIR/func -current_fontname

#define $FBXFONTNAME_ITEMS for font-name combobox
FBXFONTNAME_ITEMS=`cat /tmp/PCS-fontlist.txt`

#define $FBXFONTSIZE_ITEMS for font-size combobox
FBXFONTSIZE_ITEMS="<item>$FBXFONTSIZE</item>"
for I in 6 8 9 10 11 12 13 14 15 16 18 20 22 24; do FBXFONTSIZE_ITEMS=`echo "$FBXFONTSIZE_ITEMS<item>$I</item>"`; done

#define $FBXFONTWEIGHT_ITEMS for font-weight combobox
FBXFONTWEIGHT_ITEMS="<item>$(gettext 'medium')</item> <item>$(gettext 'bold')</item>"

#define $FBXFONTSTYLE_ITEMS for font-style combobox
FBXFONTSTYLE_ITEMS="<item>$(gettext 'roman')</item> <item>$(gettext 'italic')</item>"
fi

#---ICEWM PARAMETERS--#

if [ "`pidof icewm`" -o "`pidof icewm-session`" ]; then

#find current font attributes for the clock of IceWM
. $WORKDIR/func -current_fontname

#define $ICEWMFONTNAME_ITEMS for font-name combobox
ICEWMFONTNAME_ITEMS=`cat /tmp/PCS-fontlist.txt`

#define $ICEWMFONTSIZE_ITEMS for font-size combobox
ICEWMFONTSIZE_ITEMS="<item>$ICEWMFONTSIZE</item>"
for I in 6 8 9 10 11 12 13 14 15 16 18 20 22 24; do ICEWMFONTSIZE_ITEMS=`echo "$ICEWMFONTSIZE_ITEMS<item>$I</item>"`; done

#define $ICEWMFONTWEIGHT_ITEMS for font-weight combobox
ICEWMFONTWEIGHT_ITEMS="<item>$(gettext 'medium')</item> <item>$(gettext 'bold')</item>"

#define $ICEWMFONTSTYLE_ITEMS for font-style combobox
ICEWMFONTSTYLE_ITEMS="<item>$(gettext 'roman')</item> <item>$(gettext 'italic')</item>"

#define ICEWM minixcal option
 if [ "`which minixcal`" ]; then
	iceXCAL="
    <frame Minixcal>
   <vbox>
     <checkbox tooltip-text=\" $(gettext 'By default, a mouse-click of the tray clock will open 
 PupClockset. If you prefer a small pop-up calendar, 
 select 'Yes' and click the Set button to use minixcal.') \">
      <label>$(gettext 'Yes')</label>
      <variable>ICE_XCAL</variable>
      <input>cat $WORKDIR/ice_xcal 2>/dev/null</input>
      <action>if true echo true > $WORKDIR/ice_xcal</action>
      <action>if false echo false > $WORKDIR/ice_xcal</action>
     </checkbox>
   </vbox>
    </frame>"
 else
	iceXCAL=""
 fi
fi

#--- JWM PARAMETERS --#

if [ "`pidof jwm`" ]; then

#define current font attributes for the clock of JWM
. $WORKDIR/func -current_fontname && . $WORKDIR/func -current_fontcolor

#define $JWMFONTNAME_ITEMS for font-name combobox
JWMFONTNAME_ITEMS=`cat /tmp/PCS-fontlist.txt`

#define $JWMFONTSIZE_ITEMS for font-size combobox
JWMFONTSIZE_ITEMS="<item>$JWMFONTSIZE</item>"
for I in 6 8 9 10 11 12 13 14 15 16 18 20 22 24; do JWMFONTSIZE_ITEMS=`echo "$JWMFONTSIZE_ITEMS<item>$I</item>"`; done

#define $JWMFONTWEIGHT_ITEMS for font-weight combobox
JWMFONTWEIGHT_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'bold')</item>"

#define $JWMFONTSTYLE_ITEMS for font-style combobox
JWMFONTSTYLE_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'italic')</item>"

#define JWM minixcal option
 if [ "`which minixcal`" ]; then
	jwmXCAL="
    <frame Minixcal>
   <vbox>
     <checkbox tooltip-text=\" $(gettext 'By default, a mouse-click of the tray clock will open 
 PupClockset. If you prefer a small pop-up calendar, 
 select 'Yes' and click the Set button to use minixcal.') \">
      <label>$(gettext 'Yes')</label>
      <variable>JWM_XCAL</variable>
      <input>cat $WORKDIR/jwm_xcal 2>/dev/null</input>
      <action>if true echo true > $WORKDIR/jwm_xcal</action>
      <action>if false echo false > $WORKDIR/jwm_xcal</action>
     </checkbox>
   </vbox>
    </frame>"
 else
	jwmXCAL=""
 fi
fi

#---LXPANEL PARAMETERS--#

if [ "`pidof lxpanel`" -o "`pidof lxpanel.bin`" ]; then

#define current font color for the clock of LXPanel
. $WORKDIR/func -current_fontcolor

#define $LXPFONTSIZE_ITEMS for font-size combobox
LXPFONTSIZE_ITEMS="<item>8</item> <item>9</item> <item>10</item> <item>11</item> <item>12</item> <item>13</item> <item>14</item> <item>15</item> <item>16</item> <item>18</item> <item>20</item>"

#define $LXPFONTWEIGHT_ITEMS for font-weight combobox
LXPFONTWEIGHT_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'bold')</item>"

#define LXPanel minixcal option
 if [ "`which minixcal`" ]; then
	lxpXCAL="
    <frame Minixcal>
   <vbox>
     <checkbox tooltip-text=\" $(gettext 'By default, a mouse-click of the tray clock will open 
 PupClockset. If you prefer a small pop-up calendar, 
 select 'Yes' and click the Set button to use minixcal.') \">
      <label>$(gettext 'Yes')</label>
      <variable>LXP_XCAL</variable>
      <input>cat $WORKDIR/lxp_xcal 2>/dev/null</input>
      <action>if true echo true > $WORKDIR/lxp_xcal</action>
      <action>if false echo false > $WORKDIR/lxp_xcal</action>
     </checkbox>
   </vbox>
    </frame>"
 else
	lxpXCAL=""
 fi
fi

#--- XFCE4 PARAMETERS --#

if [ "$CURRWM" = "startxfce4" -o "$CURRWM" = "xfce4-session" -o "$CURRWM" = "xfwm4" ]; then

#define current font attributes for the clock of XFCE4
. $WORKDIR/func -current_fontname && . $WORKDIR/func -current_fontcolor

#define $XFCE4FONTNAME_ITEMS for font-name combobox
XFCE4FONTNAME_ITEMS=`cat /tmp/PCS-fontlist.txt`

#define $XFCE4FONTSIZE_ITEMS for font-size combobox
XFCE4FONTSIZE_ITEMS="<item>$XFCE4FONTSIZE</item>"
for I in 6 8 9 10 11 12 13 14 15 16 18 20 22 24; do XFCE4FONTSIZE_ITEMS=`echo "$XFCE4FONTSIZE_ITEMS<item>$I</item>"`; done

#define $XFCE4FONTWEIGHT_ITEMS for font-weight combobox
XFCE4FONTWEIGHT_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'bold')</item>"

#define $XFCE4FONTSTYLE_ITEMS for font-style combobox
XFCE4FONTSTYLE_ITEMS="<item>$(gettext 'normal')</item> <item>$(gettext 'italic')</item>"
fi

#--- FONT COLOR SELECTOR --#

if [ "`pidof fbpanel`" ]; then
	[ ! -s /tmp/fbpclockcolor.tmp ] && cat $WORKDIR/fbp.rc | grep -a FBPFONTCOLOR= | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/fbpclockcolor.tmp
	COLORSEL="
	<entry tooltip-text=\" $(gettext 'Click the color selector button') \">
	<input>cat /tmp/fbpclockcolor.tmp</input>
	<variable>FBPFONTCOLOR</variable>
	</entry>

	<colorbutton title=\"$(gettext 'PupClockset Color Selector')\" tooltip-text=\" $(gettext 'Color selector') \">
	<input file>/tmp/fbpclockcolor.tmp</input>
	<variable>FBPCOLORBUTTON</variable>
	<action>echo "'"$FBPCOLORBUTTON"'" > /tmp/fbpclockcolor.tmp</action>
	<action>refresh:FBPFONTCOLOR</action>
	</colorbutton>"

elif [ "`pidof jwm`" ]; then
	[ ! -s /tmp/jwmclockcolor.tmp ] && cat $WORKDIR/jwm.rc | grep -a JWMFONTCOLOR= | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/jwmclockcolor.tmp
	COLORSEL="
	<entry tooltip-text=\" $(gettext 'Click the color selector button') \">
	<input>cat /tmp/jwmclockcolor.tmp</input>
	<variable>JWMFONTCOLOR</variable>
	</entry>

	<colorbutton title=\"$(gettext 'PupClockset Color Selector')\" tooltip-text=\" $(gettext 'Color selector') \">
	<input file>/tmp/jwmclockcolor.tmp</input>
	<variable>JWMCOLORBUTTON</variable>
	<action>echo "'"$JWMCOLORBUTTON"'" > /tmp/jwmclockcolor.tmp</action>
	<action>refresh:JWMFONTCOLOR</action>
	</colorbutton>"

elif [ "`pidof lxpanel`" -o "`pidof lxpanel.bin`" ]; then
	[ ! -s /tmp/lxpclockcolor.tmp ] && cat $WORKDIR/lxp.rc | grep -a LXPFONTCOLOR= | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/lxpclockcolor.tmp
	COLORSEL="
	<entry tooltip-text=\" $(gettext 'Click the color selector button') \">
	<input>cat /tmp/lxpclockcolor.tmp</input>
	<variable>LXPFONTCOLOR</variable>
	</entry>

	<colorbutton title=\"$(gettext 'PupClockset Color Selector')\" tooltip-text=\" $(gettext 'Color selector') \">
	<input file>/tmp/lxpclockcolor.tmp</input>
	<variable>LXPCOLORBUTTON</variable>
	<action>echo "'"$LXPCOLORBUTTON"'" > /tmp/lxpclockcolor.tmp</action>
	<action>refresh:LXPFONTCOLOR</action>
	</colorbutton>"

elif [ "`pidof xfce4-panel`" ]; then
	[ ! -s /tmp/xfce4clockcolor.tmp ] && cat $WORKDIR/xfce4.rc | grep -a XFCE4FONTCOLOR= | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/xfce4clockcolor.tmp
	COLORSEL="
	<entry tooltip-text=\" $(gettext 'Click the color selector button') \">
	<input>cat /tmp/xfce4clockcolor.tmp</input>
	<variable>XFCE4FONTCOLOR</variable>
	</entry>

	<colorbutton title=\"$(gettext 'PupClockset Color Selector')\" tooltip-text=\" $(gettext 'Color selector') \">
	<input file>/tmp/xfce4clockcolor.tmp</input>
	<variable>XFCE4COLORBUTTON</variable>
	<action>echo "'"$XFCE4COLORBUTTON"'" > /tmp/xfce4clockcolor.tmp</action>
	<action>refresh:XFCE4FONTCOLOR</action>
	</colorbutton>"
fi

#--- CURRENT GUI --#

#define time and date for GUI text
HR12=`date +"%l"`
HR24=`date +"%H"`
MERIDIAN=`date +"%p"`
MINUTES=`date +"%M"`
MONTH=`date +"%b"`
MONTHDAY=`date +"%d"`
WEEKDAY=`date +"%a"`

#if Fbpanel is active, then find the corresponding personal strftime string and show the FbPanel tabs
if [ "`pidof fbpanel`" ]; then
PANEL="Fbpanel"
grep -a FBPFONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/FBPFONT-string
FBP_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR1</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR1</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR2</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR2</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR3</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR3</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR4</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR4</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR5</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR5</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR6</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR6</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR7</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR7</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR8</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR8</default>
     </radiobutton>
    </frame>
   </vbox>"

FBP_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox>
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/FBPFONT-string</input>
     <variable>FBPFONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
    $fbpXCAL
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <hbox>
   <vbox>
    <text><label>$(gettext 'Name')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBPFONTNAME</variable>
     <default>$FBPFONTNAME</default>
     $FBPFONTNAME_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Size')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBPFONTSIZE</variable>
     <default>$FBPFONTSIZE</default>
     $FBPFONTSIZE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>

   <hbox>
   <vbox>
    <text><label>$(gettext 'Weight')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBPFONTWEIGHT</variable>
     <default>$FBPFONTWEIGHT</default>
     $FBPFONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Style')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBPFONTSTYLE</variable>
     <default>$FBPFONTSTYLE</default>
     $FBPFONTSTYLE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>
   </vbox>

    <text><label>\"$(gettext 'Color')\"</label></text>
   <hbox>
    $COLORSEL
   </hbox>
    </frame>
   </vbox>"
else
   FBP_FORMAT=""
   FBP_OPTIONS=""
fi

#if Fluxbox is active, then find the corresponding personal strftime string and show the Fluxbox tabs
if [ "`pidof fluxbox`" ]; then
PANEL="Fluxbox"
grep -a FBXFONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/FBXFONT-string
FBX_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR9</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR9</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR10</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR10</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR11</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR11</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR12</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR12</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR13</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR13</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR14</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR14</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR15</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR15</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR16</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR16</default>
     </radiobutton>
    </frame>
   </vbox>"

FBX_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox>  
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/FBXFONT-string</input>
     <variable>FBXFONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <hbox>
   <vbox>
    <text><label>$(gettext 'Name')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBXFONTNAME</variable>
     <default>$FBXFONTNAME</default>
     $FBXFONTNAME_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Size')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBXFONTSIZE</variable>
     <default>$FBXFONTSIZE</default>
     $FBXFONTSIZE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>

   <hbox>
   <vbox>
    <text><label>$(gettext 'Weight')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBXFONTWEIGHT</variable>
     <default>$FBXFONTWEIGHT</default>
     $FBXFONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Style')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>FBXFONTSTYLE</variable>
     <default>$FBXFONTSTYLE</default>
     $FBXFONTSTYLE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>
   </vbox>
    </frame>
   </vbox>"
else
   FBX_FORMAT=""
   FBX_OPTIONS=""
fi

#if IceWM is active, then find the corresponding personal strftime string and show the IceWM tabs
if [ "`pidof icewm`" -o "`pidof icewm-session`" ]; then
PANEL="IceWM"
grep -a ICEWMFONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/ICEWMFONT-string
ICEWM_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR17</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR17</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR18</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR18</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR19</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR19</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR20</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR20</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR21</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR21</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR22</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR22</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR23</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR23</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR24</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR24</default>
     </radiobutton>
    </frame>
   </vbox>"

ICEWM_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox> 
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/ICEWMFONT-string</input>
     <variable>ICEWMFONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
    $iceXCAL
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <hbox>
   <vbox>
    <text><label>$(gettext 'Name')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>ICEWMFONTNAME</variable>
     <default>$ICEWMFONTNAME</default>
     $ICEWMFONTNAME_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Size')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>ICEWMFONTSIZE</variable>
     <default>$ICEWMFONTSIZE</default>
     $ICEWMFONTSIZE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>

   <hbox>
   <vbox>
    <text><label>$(gettext 'Weight')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>ICEWMFONTWEIGHT</variable>
     <default>$ICEWMFONTWEIGHT</default>
     $ICEWMFONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Style')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>ICEWMFONTSTYLE</variable>
     <default>$ICEWMFONTSTYLE</default>
     $ICEWMFONTSTYLE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>
   </vbox>
    </frame>
   </vbox>"
else
   ICEWM_FORMAT=""
   ICEWM_OPTIONS=""
fi

#if JWM is active, then find the corresponding personal strftime string and show the JWM tabs
if [ "`pidof jwm`" ]; then
PANEL="JWM"
grep -a JWMFONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/JWMFONT-string
JWM_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR25</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR25</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR26</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR26</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR27</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR27</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR28</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR28</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR29</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR29</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR30</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR30</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR31</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR31</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR32</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR32</default>
     </radiobutton>
    </frame>
   </vbox>"

JWM_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox>  
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/JWMFONT-string</input>
     <variable>JWMFONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
    $jwmXCAL
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <hbox>
   <vbox>
    <text><label>\"$(gettext 'Name')\"</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>JWMFONTNAME</variable>
     <default>$JWMFONTNAME</default>
     $JWMFONTNAME_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>\"$(gettext 'Size')\"</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>JWMFONTSIZE</variable>
     <default>$JWMFONTSIZE</default>
     $JWMFONTSIZE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>

   <hbox>
   <vbox>
    <text><label>\"$(gettext 'Weight')\"</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>JWMFONTWEIGHT</variable>
     <default>$JWMFONTWEIGHT</default>
     $JWMFONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>\"$(gettext 'Style')\"</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>JWMFONTSTYLE</variable>
     <default>$JWMFONTSTYLE</default>
     $JWMFONTSTYLE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>
   </vbox>

    <text><label>\"$(gettext 'Color')\"</label></text>
   <hbox>
    $COLORSEL
   </hbox>
    </frame>
   </vbox>"
else
   JWM_FORMAT=""
   JWM_OPTIONS=""
fi

#if LxPanel is active, then find the corresponding personal strftime string and show the LxPanel tabs
if [ "`pidof lxpanel`" -o "`pidof lxpanel.bin`" ]; then
PANEL="Lxpanel"
grep -a LXPFONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/LXPFONT-string
LXP_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR33</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR33</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR34</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR34</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR35</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR35</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR36</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR36</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR37</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR37</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR38</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR38</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR39</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR39</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR40</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR40</default>
     </radiobutton>
    </frame>
   </vbox>"

LXP_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox>    
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/LXPFONT-string</input>
     <variable>LXPFONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
    $lxpXCAL
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <vbox>
    <text><label>$(gettext 'Size')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>LXPFONTSIZE</variable>
     <default>$LXPFONTSIZE</default>
     $LXPFONTSIZE_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Weight')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>LXPFONTWEIGHT</variable>
     <default>$LXPFONTWEIGHT</default>
     $LXPFONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>
   </vbox>

    <text><label>\"$(gettext 'Color')\"</label></text>
   <hbox>
    $COLORSEL
   </hbox>
    </frame>
   </vbox>"
else
   LXP_FORMAT=""
   LXP_OPTIONS=""
fi

#if Xfce4 is active, then find the corresponding personal strftime string and show the Xfce4 tabs
if [ "`pidof xfce4-panel`" ]; then
PANEL="Xfce4"
grep -a XFCE4FONT_STRING $WORKDIR/clock-variables2.rc | cut -d "=" -f 2  | sed 's/\"//g' > /tmp/XFCE4FONT-string
XFCE4_FORMAT="
   <vbox>
    <frame $(gettext 'Format')>
     <radiobutton tooltip-text=\" %l:%M %p \">
      <variable>CLOCKVAR41</variable>
      <label>12 h - "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR41</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %l:%M:%S %p (or %r) \">
      <variable>CLOCKVAR42</variable>
      <label>12 h - "$HR12":"$MINUTES":00 "$MERIDIAN"</label>
      <default>$CLOCKVAR42</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %l:%M %p \">
      <variable>CLOCKVAR43</variable>
      <label>12 h - "$WEEKDAY" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR43</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %l:%M %p \">
      <variable>CLOCKVAR44</variable>
      <label>12 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR12":"$MINUTES" "$MERIDIAN"</label>
      <default>$CLOCKVAR44</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M (or %R) \">
      <variable>CLOCKVAR45</variable>
      <label>24 h - "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR45</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %H:%M:%S (or %T) \">
      <variable>CLOCKVAR46</variable>
      <label>24 h - "$HR24":"$MINUTES":00</label>
      <default>$CLOCKVAR46</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %H:%M \">
      <variable>CLOCKVAR47</variable>
      <label>24 h - "$WEEKDAY" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR47</default>
     </radiobutton>

     <radiobutton tooltip-text=\" %a %d %b %H:%M \">
      <variable>CLOCKVAR48</variable>
      <label>24 h - "$WEEKDAY" "$MONTHDAY" "$MONTH" "$HR24":"$MINUTES"</label>
      <default>$CLOCKVAR48</default>
     </radiobutton>
    </frame>
   </vbox>"

XFCE4_OPTIONS="
   <vbox>
   <hbox>
    <frame $(gettext 'Custom Format')>
   <vbox>
    <entry tooltip-text=\" $(gettext 'Enter a valid personal strftime format. 
 This will override the standard format 
 selected in the preceding tab. Please 
 note – this entry must remain blank if 
 you prefer a format from the first tab.') \" secondary-icon-stock=\"gtk-info\" secondary-icon-tooltip-text=\" $(gettext 'Open strftime manual in default browser') \">
     <input>cat /tmp/XFCE4FONT-string</input>
     <variable>XFCE4FONT_STRING</variable>
     <action signal=\"secondary-icon-release\">defaultbrowser http://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html &</action>
    </entry>
   </vbox>
    </frame>
   </hbox>

    <frame $(gettext 'Font')>
   <vbox>
   <hbox>
   <vbox>
    <text><label>$(gettext 'Name')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>XFCE4FONTNAME</variable>
     <default>$XFCE4FONTNAME</default>
     $XFCE4FONTNAME_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Size')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>XFCE4FONTSIZE</variable>
     <default>$XFCE4FONTSIZE</default>
     $XFCE4FONTSIZE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>

   <hbox>
   <vbox>
    <text><label>$(gettext 'Weight')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>XFCE4FONTWEIGHT</variable>
     <default>$XFCE4FONTWEIGHT</default>
     $XFCE4FONTWEIGHT_ITEMS
    </comboboxtext>
   </vbox>

   <vbox>
    <text><label>$(gettext 'Style')</label></text>
    <comboboxtext wrap-width=\"1\" width-request=\""$COMBOBOX_WIDTH"\">
     <variable>XFCE4FONTSTYLE</variable>
     <default>$XFCE4FONTSTYLE</default>
     $XFCE4FONTSTYLE_ITEMS
    </comboboxtext>
   </vbox>
   </hbox>
   </vbox>

    <text><label>\"$(gettext 'Color')\"</label></text>
   <hbox>
    $COLORSEL
   </hbox>
    </frame>
   </vbox>"
else
   XFCE4_FORMAT=""
   XFCE4_OPTIONS=""
fi

#set button for Hardware Clock Type
if [ "`which set_hwclock_type`" ];then
 BUTTONWIDTH="space-expand=\"true\" space-fill=\"true\""
 HWCT="
 <button $BUTTONWIDTH tooltip-text=\" $(gettext 'Set hardware clock type') \" use-underline=\"true\">
  <label>\"$(gettext '_HW-Clock')\"</label>
    <action>set_hwclock_type &</action>
 </button>"
else
 BUTTONWIDTH="width-request=\"125\""
 HWCT=""
fi

#--- MAIN DIALOG --#

export CLOCKFORMAT_DIALOG="<window title=\"PCS\" icon-name=\"clockformat48\" resizable=\"false\" window-position=\"1\">
 <vbox width-request=\"$VBOX_WIDTH\">
  <text use-markup=\"true\"><label>\"<b><span size='"'large'"'>Pup</span><span size='"'large'"' color='"$COLOR"'>Clockset</span></b>\"</label></text>
  <notebook page=\"0\" labels=\" $PANEL $(gettext 'Clock | Options | Help') \">
	$FBP_FORMAT
	$FBP_OPTIONS

	$FBX_FORMAT
	$FBX_OPTIONS

	$ICEWM_FORMAT
	$ICEWM_OPTIONS

	$JWM_FORMAT
	$JWM_OPTIONS

	$LXP_FORMAT
	$LXP_OPTIONS

	$XFCE4_FORMAT
	$XFCE4_OPTIONS

  <vbox>
    <frame $(gettext 'Ver. 2.3.1')>
     <text><label>\"  $(gettext 'A digital-tray clock will display the  
  time and date in multiple formats  
  based on standard, locale-specific  
  strftime conversion specifications.  
  PupClockset enables quick access  
  to eight common displays of time  
  and date in 12 and 24 hr formats.')\"</label></text>
     <text><label>\"
Roger D. Grider, 2015 GPL3\"</label></text>
     <pixmap><input file>$WORKDIR/icons/blank1.png</input></pixmap>
  <hbox homogeneous=\"true\">
    <button tooltip-text=\" $(gettext 'Open help file in default browser') \" use-underline=\"true\">
     <label>\" $(gettext '_Help') \"</label>
       <action>defaultbrowser /usr/local/PupClockset/Help.html &</action>
    </button>
  </hbox>
    </frame>
  </vbox>
  </notebook>

  <vbox>
  <hbox homogeneous=\"true\">
    <button $BUTTONWIDTH tooltip-text=\" $(gettext 'Personal Organizer') \" use-underline=\"true\">
     <label>\"$(gettext '_Calendar')\"</label>
       <action>[ "`which osmo`" ] && killall osmo 2>/dev/null ; osmo 2>/dev/null &</action>
       <action>[ ! "`which osmo`" ] && [ "`which orage`" ] && orage &</action>
    </button>
    $HWCT
  </hbox>
  </vbox>

  <hbox homogeneous=\"true\">
    <button width-request=\""$TRAY_BUTTON_WIDTH"\" tooltip-text=\" $(gettext 'Apply selected format') \" use-underline=\"true\">
     <label>\"$(gettext '_Set')\"</label>
      <input file stock=\"gtk-ok\"></input>
       <action>. $WORKDIR/func -clockset &</action>
       <action type=\"exit\">quit_now</action>
    </button>

    <button width-request=\""$TRAY_BUTTON_WIDTH"\" tooltip-text=\" $(gettext 'Set date and time') \" use-underline=\"true\">
     <label>\"$(gettext '_Time')\"</label>
       <action>set-time-for-puppy &</action>
    </button>

    <button width-request=\""$TRAY_BUTTON_WIDTH"\" tooltip-text=\" $(gettext 'Sync clock with time servers') \" use-underline=\"true\">
     <label>\"$(gettext 'Sy_nc')\"</label>
       <action>. $WORKDIR/func -sync_clock &</action>
    </button>

    <button width-request=\""$TRAY_BUTTON_WIDTH"\" tooltip-text=\" $(gettext 'Close PupClockset') \" use-underline=\"true\">
     <label>\"$(gettext '_Exit')\"</label>
      <input file stock=\"gtk-close\"></input>
       <action>$WORKDIR/func -restore_rc &</action>
       <action type=\"exit\">quit_now</action>
    </button>
  </hbox>
 </vbox>
</window>"

$GTKDIALOG --program=CLOCKFORMAT_DIALOG > $WORKDIR/clock-variables.rc

unset CLOCKFORMAT_DIALOG

exit 0
