#!/bin/sh

#
# Path to installation directory
#
EXEC_PATH="/opt/urserver/urserver"
PID_PATH="$HOME/.urserver/urserver.pid"
ICON_PATH="/usr/share/icons/hicolor/96x96/apps/urserver.png"

#
# Try to show notification
#
if hash notify-send 2>/dev/null; then
   notify-send -i $ICON_PATH 'Unified Remote' 'Stopping Unified Remote Server'
else
   echo "notify-send not available"
fi

#
# Try to kill the process specified by the PID file
#
if ps -p $(cat $PID_PATH) 2>/dev/null; then
   echo "stopping process"
   kill -TERM $(cat $PID_PATH)
else
   echo "process not detected"
fi

#
# Make sure the PID file is removed
#
rm $PID_PATH
