#!/bin/bash

. "${PM_FUNCTIONS}"

for opt in $PM_CMDLINE; do
	case "${opt##--quirk-}" in # just quirks, please
		bluetooth-service-off) 	   QUIRK_BLUETOOTH_SERVICE_OFF="true" ;;
		bluetooth-none) 	   QUIRK_BLUETOOTH_NONE="true" ;;
		*) continue ;;
	esac
done

quirk() { is_set "$1" && [ -z $QUIRK_BLUETOOTH_NONE ]; }

suspend_bluetooth_service()
{
	quirk "${QUIRK_BLUETOOTH_SERVICE_OFF}" &&	stopservice bluetooth
}

resume_bluetooth_service()
{
	quirk "${QUIRK_BLUETOOTH_SERVICE_OFF}" &&	restartservice bluetooth
}

help() {
	echo  # first echo makes it look nicer.
	echo "Bluetooth quirk handler options:"
	echo
	echo "  --quirk-bluetooth-service-off"
	echo "  --quirk-bluetooth-none"
}

case "$1" in
	hibernate|suspend)
		suspend_bluetooth_service
		;;
	thaw|resume)
		resume_bluetooth_service
		;;
	help) help ;;
esac
