#!/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.
#170815 easy os, icons "trash" "zip" "lock" are horizontal on top-right of screen.

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}\"/"
  sed -i -e "$APATTERN" $PUPPYPIN
  
  #170815 zip...
  RIGHTX=`expr $RIGHTX - 64`
  NEWRIGHTX=`expr $NEWRIGHTX - 64`
  APATTERN="s/x=\"${RIGHTX}\"/x=\"${NEWRIGHTX}\"/"
  sed -i -e "$APATTERN" $PUPPYPIN
  #trash...
  RIGHTX=`expr $RIGHTX - 64`
  NEWRIGHTX=`expr $NEWRIGHTX - 64`
  APATTERN="s/x=\"${RIGHTX}\"/x=\"${NEWRIGHTX}\"/"
  sed -i -e "$APATTERN" $PUPPYPIN
  
 fi

fi


###END###
