#! /bin/bash

#this script was written by the MX Linux Dev Team in January 2020
#its function is to change the default toolbar to a legacy look
#and to establish the means of return

#dependency: wmalauncher (installed by default in MX-Fluxbox versions > 1.2

TEXTDOMAINDIR=/usr/share/locale
export TEXTDOMAIN="mx-fluxbox"

TITLE1=$"OK to proceed?"
MSG=$"This will make changes required for a legacy toolbar layout. Your current settings will be backed up and can be restored by clicking Menu > Settings > Toolbar > Userlast"
TITLE2=$"All done!"
END_MSG=$"Log out and back in to complete the change."

##begin msg box
yad --text="


<b>$MSG</b>" --title="$TITLE1" --window-icon=/usr/share/icons/mxflux.png --geometry=400x30 --text-align=center --button=gtk-cancel:1 --button=gtk-yes:0


##end message box

case $? in

             0)     ;;

             1)     exit 0    ;;

	  252)     exit 0    ;;

             
esac

#create a backup for "userlast" entry

mkdir -p $HOME/.restore/fluxbox
cd $HOME/.fluxbox	
cp  init apps startup $HOME/.restore/fluxbox/

#set up wmalauncher 
sed -i "s/"#wmalauncher-menu"/"wmalauncher-menu"/" $HOME/.fluxbox/startup


#make init changes
sed -i 's/^session.screen0.toolbar.tools:.*/session.screen0.toolbar.tools:  nextworkspace, workspacename, prevworkspace, iconbar, systemtray, clock/' $HOME/.fluxbox/init
sed -i 's/^session.screen0.slit.placement:.*/session.screen0.slit.placement: BottomLeft/' $HOME/.fluxbox/init
sed -i 's/^session.screen0.toolbar.widthPercent:.*/session.screen0.toolbar.widthPercent: 97/' $HOME/.fluxbox/init
sed -i 's/^session.screen0.toolbar.placement:.*/session.screen0.toolbar.placement: BottomRight/' $HOME/.fluxbox/init

##begin end_msg box
yad --text="


<b>$END_MSG</b>" --title=$"All done!" --window-icon=/usr/share/icons/mxflux.png --geometry=400x40 --text-align=center 
##end end_msg box


exit

