#!/bin/sh
#jwm-menu
if [ -x $(which jwm-menu-bash 2>/dev/null) ]
then
  $(which jwm-menu-bash)
  echo "updated jwm-menu-bash"
fi
if [ -x $(which jwm-menu 2>/dev/null) ]
then
  jwm-menu --reload
  echo "updated jwm-menu"
fi
if [ -x $(which jwm-places-bash 2>/dev/null) ]
then
  $(which jwm-places-bash)
  echo "updated jwm-places-bash"
fi
if [ -x $(which jwm-places 2>/dev/null) ]
then
  $(which jwm-places)
  echo "updated jwm-places"
fi

if [ -n "$(pgrep jwm 2>/dev/null)" ]
then
  jwm -p
  if [ $? -ne 0 ]
  then
    if [ "$(whoami)" != "root" ]
    then
      echo "There was an error in your JWM configuration"
    else
      echo "You are running $0 as root, and this may not regenerate your user specific menus correctly, please rerun $0 as non-root"
    fi
  else
    jwm -reload
    echo "Restarting JWM"
  fi
fi
exit 0
