re='^[\+0-9\#\*\-]+$'
if ! [[ $1 =~ $re ]] ; then
  echo searching contacts for "$1"
  number=$(contacts $1 | head -n 1 | awk '{print $1}');
else
  # if length is less than 7 then do dtmf chars
  # this is ok for text because you can't text 911
  # for d(ial) we will need to only do dtmf for 2 or less chars

  if [ ${#1} -lt 7 ] ;  then
#    echo "number was ${#1} chars long so do dtmf"
    for (( i=0 ; i < ${#1} ; i++ )) ; do
      echo would call dtmf ${1:$i:1};
#      dtmf ${1:$i:1};
      sleep 0.1;
    done
    exit
  fi
  number=$1;
fi

echo dialing $number ...
echo $number > ~/.lastnumber

dial $number


# todo, instead of calling handset-unmuted... pay attention to current state of handset|headset|speaker mic mute|headset mute...

#!/bin/sh
#handset-unmuted
#volume 7
