#!/bin/sh
# powernap action to suspend the system using `systemctl hybrid-sleep`

set -e

if [ "$1" = "true" ]
then
	systemctl hybrid-sleep
	
	if [ -n "$POWERNAP_PID" ]
	then
		kill -USR1 "$POWERNAP_PID"
	fi
elif [ "$1" = "false" ]
then
	# Do nothing
	true
else
	echo "Usage: $0 <true|false>" 2>&1
	exit 64 # EX_USAGE
fi
