#!/bin/sh -e

# When the computer comes out of hibernate/suspend kill the old event client
# and start a new one.

EVENT_CLIENT=/usr/bin/kodi_hama_mce
SYSTEMD_SCRIPT=kodi_hama_mce.service

case "$1" in
    resume|thaw)
        if [ -x ${EVENT_CLIENT} ]; then
            systemctl stop ${SYSTEMD_SCRIPT} || true
            sleep 2
            systemctl start ${SYSTEMD_SCRIPT}
        fi
    ;;
esac
