#!/bin/sh
#(c) Copyright Barry Kauler 2006 www.puppylinux.com
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#BK Aug/Sept 2007: bugfixes for v2.20, 2.21
#BK Oct 2007: bugfix new version xrandr v3.02
#v3.99 BK apr 2008: workaround for dual monitors.
#v404 change to xwininfo, tidyup.

PUPPYPIN="$1"
[ "$PUPPYPIN" = "" ] && PUPPYPIN="/root/Choices/ROX-Filer/PuppyPin"

SCREENX=`xwininfo -root | grep -o '\-geometry.*x' | cut -f 2 -d ' ' | cut -f 1 -d 'x'`

if [ $SCREENX ];then

 #find out current right side in PuppyPin...
 RIGHTX=`grep 'Xlock' $PUPPYPIN | cut -f 2 -d '"'` #'Geany fix

 #all icons on right side of screen will be relocated to correct right side...
 NEWRIGHTX=`expr $SCREENX - 32`
 if [ "$RIGHTX" != "$NEWRIGHTX" ];then
  APATTERN="s/x=\"${RIGHTX}\"/x=\"${NEWRIGHTX}\"/"
  cat $PUPPYPIN | sed -e "$APATTERN" > /tmp/PuppyPin
  sync
  cp -f /tmp/PuppyPin $PUPPYPIN
 fi

fi


###END###
