The following simple bash script solved the problem:
Code:
#! /bin/bash
# this is the script that will start X
COMMAND="startgui.sh"
RES_BACKUP=""
RES=""
JID=""
function updateJID ()
{
JID=`jobs | grep "$COMMAND" | grep -o -e[0-9]*\] | grep -o -e[0-9]*`
}
function getScreenRes ()
{
RES=`su -l xuser -c "xdpyinfo -display :0| grep dimensions | grep -o -e[0-9][0-9]*x[0-9]* | head -n 1"`
}
function refreshDesktop ()
{
echo "Updating screen to $RES_BACKUP"
su -l xuser -c "DISPLAY=:0.0 fbsetbg -F /home/xuser/.fluxbox/backgrounds/BRN.png"
}
/etc/startgui.sh &
updateJID
while [ $JID ]
do
sleep 1
# Be sure to update the loop condition variable
updateJID
# Next make sure that the screen size didn't change
getScreenRes
if [ ! "$RES" = "$RES_BACKUP" ]; then
RES_BACKUP="$RES"
refreshDesktop
fi
done