#!/bin/sh

# PROVIDE: aird
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf or /etc/rc.conf.local to
# enable aird:
# aird_enable (bool):	Set to "NO" by default.
# aird_key:		Unset by default; see man page on pairing.
#
# The following options have defaults sane for musicpd, they can be reassigned
# in /etc/rc.conf
#
# aird_play, aird_forward, aird_up, aird_down, aird_back, aird_menu

. /etc/rc.subr

name="aird"
rcvar=aird_enable

load_rc_config $name

: ${aird_enable="NO"}
: ${aird_play="/usr/local/bin/mpc toggle"}
: ${aird_forward="/usr/local/bin/mpc next"}
: ${aird_up="/usr/sbin/mixer vol +2"}
: ${aird_down="/usr/sbin/mixer vol -2"}
: ${aird_back="/usr/local/bin/mpc prev"}
: ${aird_menu="/usr/local/bin/xterm -e ncmpc"}

aird_key="${aird_key:+-k ${aird_key}}"

command="/usr/local/bin/aird"
pidfile="/var/run/aird.pid"
command_args="-p ${pidfile} -f /dev/uhid1 ${aird_key}\
	-P \"${aird_play}\"	\
	-F \"${aird_forward}\"	\
	-U \"${aird_up}\"	\
	-D \"${aird_down}\"	\
	-B \"${aird_back}\"	\
	-M \"${aird_menu}\""

run_rc_command "$1"
