diff options
author | B. Watson <yalhcru@gmail.com> | 2013-06-26 19:54:07 -0300 |
---|---|---|
committer | Niels Horn <niels.horn@slackbuilds.org> | 2013-06-26 19:54:07 -0300 |
commit | f4fc936b4de1e5b274e77baeeea3858aa8a1270e (patch) | |
tree | 81e5a90b3412257cdbe4bf8b9c89fbccc7a7bab7 /misc/cwiid/rc.cwiid.new | |
parent | 4451a38cd8d05d3bbbd12f55f3c0b2830b553230 (diff) | |
download | slackbuilds-f4fc936b4de1e5b274e77baeeea3858aa8a1270e.tar.gz |
misc/cwiid: Updated for version 0.6.00+svn201.
Signed-off-by: Niels Horn <niels.horn@slackbuilds.org>
Diffstat (limited to 'misc/cwiid/rc.cwiid.new')
-rw-r--r-- | misc/cwiid/rc.cwiid.new | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/misc/cwiid/rc.cwiid.new b/misc/cwiid/rc.cwiid.new new file mode 100644 index 0000000000..3efb8e4334 --- /dev/null +++ b/misc/cwiid/rc.cwiid.new @@ -0,0 +1,89 @@ +#!/bin/sh + +# RC script for cwiid's wminput daemon, part of the SBo cwiid package. + +# Where's the config file for this script? This is the only variable that can't +# be overridden in the config file. +RC_CONF=/etc/rc.d/rc.cwiid.conf + +#### +# Override this stuff in $RC_CONF if you see a need to: + +# Default config file for wminput instances +WMINPUT_DEFAULT_CONF=default + +# full path to wminput binary: +WMINPUT_BIN=/usr/bin/wminput + +# probably nobody will ever need to increase this: +MAX_WIIMOTES=9 + +#### + +start_cwiid() { + local cwiid_conf + local cwiid_addr + local cmd + local daemons + + echo "Starting cwiid wminput daemon(s)..." + + # Guarantee the uinput module gets loaded, don't complain if not + # (it may not be modular in the running kernel) + /sbin/modprobe uinput &>/dev/null + + # WIIMOTE is a bash array, will be populated by config file or default conf + unset WIIMOTE + + if [ -r "$RC_CONF" ]; then + source $RC_CONF + else + echo -e "$RC_CONF missing, using defaults:\\n\\tWIIMOTE[0]='auto'\\n\\tWIIMOTE_CONF[0]='$WMINPUT_DEFAULT_CONF'" 1>&2 + WIIMOTE[0]=auto + fi + + i=0 + daemons=0 + while [ $i -le $MAX_WIIMOTES ]; do + if [ -n "${WIIMOTE[$i]}" ]; then + cwiid_conf="${WIIMOTE_CONF[$i]:-$WMINPUT_DEFAULT_CONF}" + cwiid_addr=${WIIMOTE[$i]} + + if [ "$cwiid_addr" = "auto" ]; then + cwiid_addr="" + fi + + cmd="$WMINPUT_BIN -d -c $cwiid_conf $cwiid_addr" + echo " Starting daemon: $cmd" + $cmd & + + daemons=$((daemons+1)) + fi + + i=$((i+1)) + done + echo "cwiid startup done, $daemons daemons started" +} + +stop_cwiid() { + echo -n "Stopping cwiid wminput daemon(s)..." + killall wminput &>/dev/null + sleep 2 + killall -9 wminput &>/dev/null + echo "done" +} + +case "$1" in + start) start_cwiid ;; + stop) stop_cwiid ;; + restart) + stop_cwiid + sleep 1 + start_cwiid + ;; + *) + echo "Usage: $0 start|stop|restart" 1>&2 + exit 1 + ;; +esac +exit 0 |