#!/bin/sh
#100704 this was originally in Nathan's Wallpaper package.
# called by 'pwallpaper' wallpaper setter.

# Determine the path to this application.
CURDIR="`pwd`"
APPDIR=`dirname "$0"`
cd "${APPDIR}"
APPDIR="`pwd`"
cd "${CURDIR}"

if [ "$1" = "-clear" ];then
 grep -v '<backdrop' $HOME/.config/rox.sourceforge.net/ROX-Filer/pb_default  > $HOME/.config/wallpaper/pb
 mv -f $HOME/.config/wallpaper/pb $HOME/.config/rox.sourceforge.net/ROX-Filer/pb_default
 rox -p=default
 echo "[none]" > $HOME/.config/wallpaper/bg_img
 exit
fi

MODE="`cat $HOME/.config/wallpaper/backgroundmode`"
[ "$MODE" = "" ] && MODE="Scale"
[ "$MODE" = "Centred" ] && MODE="Centre"
[ "$MODE" = "Scaled" ] && MODE="Scale"

#w482 BK now have script that truncates an image vertically so that it has the right dimensions
#for a widescreen...
if [ "$MODE" = "Stretch" ];then
 /usr/sbin/background_reshape ${1}
fi

rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <SetBackdrop>
   <Filename>$1</Filename>
   <Style>$MODE</Style>
  </SetBackdrop>
 </env:Body>
</env:Envelope>

EOF
