#!/bin/bash
#################################################################################
# This script fix the error - Warning: Actions not found: delete-next-character
# when using mathematica in SuSE 9.0 and up
#################################################################################


#---- Creat file /usr/X11R6/lib/X11/app-defaults/XMathemathica --------->

creatXMath() {

/usr/bin/touch /usr/X11R6/lib/X11/app-defaults/XMathemathica
/bin/cat > /usr/X11R6/lib/X11/app-defaults/XMathemathica << EOF
Xmathematica*Text.Translations:     #override \n\\
~Shift ~Meta ~Alt Delete:       \n

XMathematica*AxeText.Translations:  #override \n\\
~Shift ~Meta ~Alt Delete:       \n

XMathematica*XmText.Translations:   #override \n\\
~Shift ~Meta ~Alt Delete:       \n\\
~Shift ~Meta ~Alt osfDelete:    \n\\

XMathematica*XmTextField.Translations: #augment \n\\
~Shift ~Meta ~Alt osfDelete:    \n\\

EOF
}


#------- Creat file ~/.Xresources ------------>

creatXresource() {
/usr/bin/touch ~/.Xresources
/bin/cat >  ~/.Xresources << EOF
*secondaryModifierMask: Mod3Mask
EOF
}



#------------- Main ---------->

if ! [ -e /usr/X11R6/lib/X11/app-defaults/XMathemathica ] ; then
creatXMath
fi

if ! [ -e ~/.Xresources ] ; then
creatXresource
fi

xrdb -load ~/.Xresources
/usr/local/bin/Mathematica

