#!/bin/bash
#
# simple none interactiv handler for Bluetooth PIN's
# /etc/bluetooth/pin must only contain one line with the
# PIN code
# With big enhancements from Serguei Leontiev <leo@sai.msu.ru>
#

# if e.g. kbluetoothd is not running, kbluepin throws an error and returns 1
KBLUETOOTHD_RUN=`ps -ea|grep kbluetoothd`
KBLUEPIN=${KBLUEPIN:-/opt/kde3/sbin/kbluepin}
if [ -x ${KBLUEPIN} \
   -a "X$KBLUETOOTHD_RUN" != "X" ]; then
   PIN=`$KBLUEPIN "$@"` && {
       case "$PIN" in
         PIN:*)
           echo "$PIN"
           exit 0
           ;;
       esac
   }
fi;

echo -n "PIN:"
cat /etc/bluetooth/pin
