#!/bin/sh

# Work-around for OpenJDK bug, which causes displaying only empty gray
# windows when used with non-re-parenting window managers, such as Awesome.
# See e.g.: http://awesome.naquadah.org/wiki/Problems_with_Java
export _JAVA_AWT_WM_NONREPARENTING=1

prefix=/usr
exec_prefix=${prefix}
datarootdir=${prefix}/share
datadir=${datarootdir}
bindir=${exec_prefix}/bin

cd
"$bindir/poliqarpd" --gui --detach 2>/dev/null
for dir in /usr/lib/jvm/java-7-openjdk* /usr/lib/jvm/java-6-openjdk* /usr/lib/jvm/java-6-sun-* /usr/lib/jvm/java-1.5.*-sun-* ''
do
   if [ -n "$dir" ]
   then 
      [ -d "$dir" ] || continue
      dir="$dir/bin/"
   fi
   if [ -z "$dir" ] || [ -x "${dir}java" ]
   then
      exec "${dir}java" -jar "$datadir/poliqarp/poliqarp.jar"
   fi
done
