#!/bin/sh

# Run commands in conjunction with suspend/resume.
# This is a more configurable alternative to editing rc.suspend/rc.resume.

# Author: S. Ross Gohlke <ross@bisd.ro>
# License: BSD

# PROVIDE: sleep
# REQUIRE: LOGIN
# KEYWORD: suspend resume

. /etc/rc.subr

# Options #

# Set options in rc.conf(5).

## Global ##

#sleep_enable="NO"

# List command(s) to run before suspend and after resume.

#sleep_suspend=""
#sleep_resume=""

# Configuration #

name="sleep"
desc="Run commands in conjunction with suspend/resume"
rcvar="${name}_enable"

start_cmd=":"
stop_cmd=":"
extra_commands="suspend resume"
suspend_cmd="${name}_suspend"
suspend_precmd='[ -n "$sleep_suspend" ]'
resume_cmd="${name}_resume"
resume_precmd='[ -n "$sleep_resume" ]'

# Subroutines #

sleep_suspend() {
	$sleep_suspend
}

sleep_resume() {
	$sleep_resume
}

# Operation #

load_rc_config $name
run_rc_command "$1"
