#!/bin/sh

if [ $# = 0 ] ; then
  echo "Usage: upgrade_theme theme_dir_1 [theme_dir_2 ... theme_dir_n]"
fi

for theme in $* ; do
  if [ -d "$theme" ] ; then
    echo "Upgrading theme $theme..."
    if [ ! -e "$theme/title-active-shaded.xpm" ] ; then
      cp "$theme/title-active.xpm" "$theme/title-active-shaded.xpm"
    else
      echo "  $theme/title-active-shaded.xpm already exists."
    fi
    if [ ! -e "$theme/title-inactive-shaded.xpm" ] ; then
      cp "$theme/title-inactive.xpm" "$theme/title-inactive-shaded.xpm"
    else
      echo "  $theme/title-inactive-shaded.xpm already exists."
    fi
    if [ ! -e "$theme/top-left-active-shaded.xpm" ] ; then
      cp "$theme/top-left-active.xpm" "$theme/top-left-active-shaded.xpm"
    else
      echo "  $theme/top-left-active-shaded.xpm already exists."
    fi
    if [ ! -e "$theme/top-left-inactive-shaded.xpm" ] ; then
      cp "$theme/top-left-inactive.xpm" "$theme/top-left-inactive-shaded.xpm"
    else
      echo "  $theme/top-left-inactive-shaded.xpm already exists."
    fi
    if [ ! -e "$theme/top-right-active-shaded.xpm" ] ; then
      cp "$theme/top-right-active.xpm" "$theme/top-right-active-shaded.xpm"
    else
      echo "  $theme/top-right-active-shaded.xpm already exists."
    fi
    if [ ! -e "$theme/top-right-inactive-shaded.xpm" ] ; then
      cp "$theme/top-right-inactive.xpm" "$theme/top-right-inactive-shaded.xpm"
    else
      echo "  $theme/top-right-inactive-shaded.xpm already exists."
    fi
  else 
    echo "$theme is not a directory."
  fi
done
