~mil/f_scripts

a384f352d419a3ba710e33ee8f90dae45247d4b4 — Miles Alan 2 years ago 8b2d50f
f_phone: Style cleanups
1 files changed, 13 insertions(+), 27 deletions(-)

M scripts/f_phone
M scripts/f_phone => scripts/f_phone +13 -27
@@ 31,6 31,13 @@ VAR="
  F_PHONE_COUNTRYCODE='US'
"

cleannumber() { pn find -c "$F_PHONE_COUNTRYCODE" "$1"; }
mm() { mmcli -m 0 "$@"; }
monitorstateget() { cat "$F_PHONE_MONITORSTATEFILE" || echo ""; }
monitorstateset() { echo "$1" > "$F_PHONE_MONITORSTATEFILE"; }
ringhangup() { mm -o "$(callid "incoming.+ringing")" --hangup; }
ringpickup() { loopincall --accept "$(callid "incoming.+ringing")"; }

promptok() {
  [ -p /tmp/fbp.fifo ] && echo -e "\b\f\rok" > /tmp/fbp.fifo
  read -p Ok foo


@@ 50,10 57,6 @@ terminate() {
  exit 1
}

mm() {
  mmcli -m 0 "$@"
}

installpolkitudevrules() {
  TARGETPOLKITFILE="/etc/polkit-1/rules.d/00-f_scripts-fphone-mmplugdev.rules"
  TARGETUDEVFILE="/etc/udev/rules.d/00-f-scripts-f-phone.rules"


@@ 94,7 97,7 @@ installpolkitudevrules() {
ensuremmrunning() {
  rc-service modemmanager status | grep started || {
    sudo /etc/init.d/modemmanager start
    sudo /etc/init.d/modemmanager enable
    sudo rc-update modemmanager enable
  }
}



@@ 201,9 204,6 @@ modemrst() {
  done
}

cleannumber() {
  pn find -c "$F_PHONE_COUNTRYCODE" "$1"
}

callid() {
  TYPE="$1"


@@ 294,13 294,6 @@ phonelog() {
  done
}

monitorstateget() {
  cat "$F_PHONE_MONITORSTATEFILE" || echo ""
}

monitorstateset() {
  echo "$1" > "$F_PHONE_MONITORSTATEFILE"
}

determinemodemtransition() {
  local MONITORSTATE


@@ 344,15 337,15 @@ syncmmstatetolog() {
  done

  for CALLID in $(
    mmcli -m "$(modem_n)" --voice-list-calls |
    grep terminated |
    grep -oE "Call\/[0-9]+" |
    cut -d'/' -f2
    mm --voice-list-calls |
      grep terminated |
      grep -oE "Call\/[0-9]+" |
      cut -d'/' -f2
  ); do
    NUM="$(lookupnumberfromcallid "$CALLID")"

    logevt callterminate "$(date +%s)" "$NUM"
    mmcli -m "$(modem_n)" --voice-delete-call "$CALLID"
    mm --voice-delete-call "$CALLID"
  done
}



@@ 384,13 377,6 @@ monitorboot() {
  done
}

ringpickup() {
  loopincall --accept "$(callid "incoming.+ringing")"
}

ringhangup() {
  mm -o "$(callid "incoming.+ringing")" --hangup
}

mainloop() {
  while true; do