#!/bin/sh

#DEBHELPER#

if [ "$1" != "triggered" ]; then
	start --quiet headphoned
fi

policy_file=/usr/share/policy/etc/rx51/pulse/xpolicy.conf

if [ ! -e $policy_file ]; then
	exit 0 # Having to modify the policy file isn't critical as such
fi

grep headphoned $policy_file > /dev/null

if [ $? == 1 ]; then
	if [ ! -e $policy_file.old ]; then
		cp $policy_file $policy_file.old
	fi
	echo >> $policy_file
	echo "[stream]" >> $policy_file
	echo "exe   = headphoned" >> $policy_file
	echo "group = alwayson" >> $policy_file #Using the "EOF" trick would be better, I guess, but I'm lazy
fi
