I once had a similar setup for a while in another distro, although I used case instead of individual tests.
Also, since fluxbox sets the background itself, I don't think you need to specifically call Esetroot for that window manager.
Also also, you can save some bytes by using a variable for your image filename and use just one command to set the background
Also also also, it looks like you're setting the background twice. If you run Esetroot from .xsession, there should be no need to use .setbackground
case "$DESKTOP" in
fluxbox) BG=12.jpg ;;
jwm) BG=2.jpg; [ "$ICONS" == "wbar" ] && /usr/bin/wbar.sh ;;
esac
Esetroot -s /opt/.backgrounds/$BG
An alternative, if you want to still use .setbackground (i think it might be used by the wallpaper tool?)...
case "$DESKTOP" in
fluxbox) BG=12.jpg ;;
jwm) BG=2.jpg; [ "$ICONS" == "wbar" ] && /usr/bin/wbar.sh ;;
esac
echo "Esetroot -s /opt/.backgrounds/$BG" > .setbackground
[ -x .setbackground ] && sh .setbackground
EDIT: I noticed an error with my script. If you do echo "Esetroot -s /opt/.backgrounds/$BG" > .setbackground, it can't be run as an executable script because the "#!/bin/sh" is gone, so I changed it to sh .setbackground