#!/bin/sh
PATH="$(dirname $0):$PATH"
class=$(gutenbach-get-config zephyr-class)
host=$(gutenbach-get-config host)
queue=$(gutenbach-get-config queue)
instance="$queue-volume@$host"

mixer=$(gutenbach-get-config mixer)
channel=$(gutenbach-get-config channel)

muted=$(volume-is-muted)
mute_str=" [$muted]"
if [ "$muted" = "unmuted" ]; then
    mute_str=""
fi

start-stop-daemon --stop --oknodo --pidfile /usr/lib/gutenbach/gutenbach-zephyr >/dev/null 2>&1
start-stop-daemon --start --pidfile /usr/lib/gutenbach/gutenbach-zephyr --make-pidfile --background --exec /bin/sh -- -c "sleep 10 && zwrite -c $class -i $instance -d -n -m '$REMOTE_USER set volume $(volume-get)$mute_str' > /dev/null" >/dev/null 2>&1
