#!/bin/sh

if test ! -d ~/.blackbox
then
  mkdir ~/.blackbox
fi

if test ! -d ~/.blackbox/Styles
then
  mkdir ~/.blackbox/Styles
fi

if test ! -f ~/.blackbox/Menu
then
  echo
  if test $1
  then
    if test $1 = "--help" || test $1 = "-help" || test $1 = "-h" || test $1 = "--h"
    then
      echo Run this program without arguments
      echo
      exit
    fi
    if test $1 = "--mymenu" || $1 = "-mymenu"
    then
      touch ~/.blackbox/Menu
      chmod u+w ~/.blackbox/Menu
    fi
    if test ! -f $1
    then
      echo File: ${1} not found
      echo
      exit
    else
      cp ${1} ~/.blackbox/Menu
      chmod u+w ~/.blackbox/Menu
    fi
  else
    echo Ignore this if you already have a custom root menu defined
    echo in ~/.blackboxrc
    echo -n Looking for default blackbox menu in usuall locations...
    if test -f /usr/X11R6/share/Blackbox/menu
    then
      cp /usr/X11R6/share/Blackbox/menu ~/.blackbox/Menu
      echo found
    elif test -f /usr/share/Blackbox/menu
    then
      cp /usr/share/Blackbox/menu ~/.blackbox/Menu
      echo found
    elif test -f /usr/local/share/Blackbox/menu
    then
      cp /usr/local/share/Blackbox/menu ~/.blackbox/Menu
      echo found
    else
      echo not found
      echo If you have a custom menu defined in ~/.blackboxrc already,
      echo run this command again with an argument of --mymenu
      echo Example: bbrb.inst --mymenu
      echo If not, run this command again with the location of the file.
      echo Example: bbrb.inst /opt/Blackbox/menu
      echo If you have locate installed, you can run: locate Blackbox/menu
      echo to find where it is located.
      echo
      exit
    fi
    chmod u+w ~/.blackbox/Menu
  fi
fi

if test -f ~/.blackbox/bgMenu
then
  echo You have already installed bbrb
  echo
  exit
fi

bbrb -preinst
bbrb -inst
echo
echo You can ignore all errors.
echo "If you didn't already have a custom root menu for blackbox, one"
echo will have been made for you. It should be stored in ~/.blackbox/Menu
echo You can edit it how you see fit.
echo
echo You should now be able to launch bbrb from the blackbox root menu.
echo Look under the Backgrounds submenu.
echo

