add contacts.tsv integration to call and text apps

Signed-off-by: Miles Alan <m@milesalan.com>
This commit is contained in:
Anjandev Momi 2020-06-18 18:52:38 -07:00 committed by Miles Alan
parent ff9ddcb634
commit f95cb51984
4 changed files with 47 additions and 18 deletions

View file

@ -22,12 +22,6 @@ modem_n() {
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
}
contacts() {
RES="$(cut -f3 "$LOGDIR/modemlog.tsv" | sort | uniq | awk NF)"
echo "$RES"
printf %b "$RES" | grep -q 8042221111 || echo "Test Number 8042221111"
}
modem_cmd_errcheck() {
RES="$(mmcli "$@" 2>&1)"
OK="$?"

View file

@ -17,7 +17,7 @@ modem_n() {
}
dialmenu() {
CONTACTS="$(contacts)"
CONTACTS="$(sxmo_contacts.sh)"
NUMBER="$(
printf %b "Close Menu\n$CONTACTS" |
grep . |
@ -25,7 +25,12 @@ dialmenu() {
)"
echo "$NUMBER" | grep "Close Menu" && kill 0
NUMBER="$(echo "$NUMBER" | awk -F' ' '{print $NF}' | tr -d -)"
NUMBER="$(
echo "$NUMBER" |
awk -F' ' '{print $NF}' |
tr -d - |
cut -f2
)"
echo "$NUMBER" | grep -qE '^[+0-9]+$' || fatalerr "$NUMBER is not a number"
echo "Attempting to dial: $NUMBER" >&2

View file

@ -13,11 +13,6 @@ modem_n() {
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
}
textcontacts() {
# TODO: is find automatically sorted by timestamp?
find "$LOGDIR"/* -type d -maxdepth 1 | awk -F'/' '{print $NF}' | tac
}
editmsg() {
TMP="$(mktemp --suffix "$1_msg")"
echo "$2" > "$TMP"
@ -81,12 +76,12 @@ tailtextlog() {
main() {
# Display
ENTRIES="$(printf %b "$(textcontacts)" | xargs -INUM echo NUM logfile)"
ENTRIES="$(printf %b "$(sxmo_contacts.sh)" | xargs -INUM echo NUM logfile)"
ENTRIES="$(printf %b "Close Menu\nSend a Text\n$ENTRIES")"
NUMBER="$(printf %b "$ENTRIES" | dmenu -p Texts -c -fn Terminus-20 -l 10)"
echo "$NUMBER" | grep "Close Menu" && exit 1
echo "$NUMBER" | grep "Send a Text" && sendtextmenu && exit 1
tailtextlog "$(echo "$NUMBER" | sed 's/ logfile//g')"
CONTACTIDANDNUM="$(printf %b "$ENTRIES" | dmenu -p Texts -c -fn Terminus-20 -l 10)"
echo "$CONTACTIDANDNUM" | grep "Close Menu" && exit 1
echo "$CONTACTIDANDNUM" | grep "Send a Text" && sendtextmenu && exit 1
tailtextlog "$(echo "$CONTACTIDANDNUM" | grep -Eo "[0-9]{3,}")"
}
main