#!/bin/sh
BASE=/usr/apps/Settings/Backdrop
BACKDROP=/tmp/backdrop
PIXMAPS=/usr/share/pixmaps
OPTION="$1"
IMAGE="$2"

case $OPTION in
  --help|-help|--h|-h)
    echo "rox-bset 0.1 by Hd Luc"
    echo "usage: rox-bset [--update]|[--portrait]|[--landscape]|[--random]"
    ;;
  --random|-random|--r|-r)
    if [ -f /usr/apps/Settings/Wallpaper/AppRun ]; then
      echo "switching to Wallpaper (random backdrop)"
      rox -R < $BASE/wallpaper.xml
    else
      echo "Wallpaper (random backdrop) not found!"
    fi
    ;;
  --update|-update|--u|-u)
    rox -R < $BASE/backdrop.xml
    if [ "$IMAGE" != "" ]; then
      echo "stretch $IMAGE" >$BACKDROP
    else
      echo "stretch $PIXMAPS/Wallpapers/background.png" >$BACKDROP
    fi
    ;;
  --portrait|-portrait|--p|-p)
    rox -R < $BASE/backdrop.xml
    if [ -f $PIXMAPS/Wallpapers/background-v.png ]; then
      echo "stretch $PIXMAPS/Wallpapers/background-v.png" >$BACKDROP
    else
      echo "stretch $PIXMAPS/Wallpapers/background.png" >$BACKDROP
    fi
    ;;
  --landscape|-landscape|--l|-l)
    rox -R < $BASE/backdrop.xml
    if [ -f $PIXMAPS/Wallpapers/background-h.png ]; then
      echo "stretch $PIXMAPS/Wallpapers/background-h.png" >$BACKDROP
    else
      echo "stretch $PIXMAPS/Wallpapers/background.png" >$BACKDROP
    fi
    ;;
  *)
    if [ ! -f $BACKDROP ]; then
      echo "stretch $PIXMAPS/Wallpapers/background.png" >$BACKDROP
    fi
    cat $BACKDROP
    ;;
esac
exit 0
