#!/bin/bash

. /usr/lib/pm-utils/functions

suspend() {
    # Send a signal to cheese to indicate suspend
    killall -SIGUSR1 cheese && sleep 4  
}

resume() {
    # If cheese is running, send it a signal to indicate resume
    # (insert a short delay to help the cheese gstreamer pipeline
    # to restart successfully)
    if ps ax | grep cheese | grep -v grep > /dev/null
    then 
      sleep 4
      killall -SIGUSR2 cheese
    fi
}

case "$1" in
	hibernate|suspend)
		suspend
		;;
	thaw|resume)
		resume
		;;
	*)
		;;
esac

exit $?
