From 65d9d60ff15c62554b1589aad1163d8c1d31328b Mon Sep 17 00:00:00 2001 From: Reed Wade Date: Fri, 30 Oct 2020 12:06:56 +0100 Subject: [PATCH] Add more contacts choice to contact list The dialer only included recent callers, but there was no way to access the full contact list (contacts.tsv). I added a "more contacts" options that calls sxmo_contacts --all, providing an alphabetically sorted list of all your contacts. It also works for the texting menu. This is a cleaned up version of an earlier patch by Maarten van Gompel. Signed-off-by: Maarten van Gompel --- scripts/core/sxmo_contacts.sh | 12 +++++++++++- scripts/modem/sxmo_modemdial.sh | 11 ++++++++--- scripts/modem/sxmo_modemtext.sh | 11 +++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/core/sxmo_contacts.sh b/scripts/core/sxmo_contacts.sh index 1acc638..bdddc7a 100755 --- a/scripts/core/sxmo_contacts.sh +++ b/scripts/core/sxmo_contacts.sh @@ -28,4 +28,14 @@ contacts() { ' "$CONTACTSFILE" - } -contacts +all_contacts() { + cat "$CONTACTSFILE" | awk -F'\t' '{ + if (substr($0,1,1) == "+") print $1 ": " $2 + }' | sort -f -k 2 +} + +if [ "$1" = "--all" ]; then + all_contacts +else + contacts +fi diff --git a/scripts/modem/sxmo_modemdial.sh b/scripts/modem/sxmo_modemdial.sh index 711144d..66ff8a9 100755 --- a/scripts/modem/sxmo_modemdial.sh +++ b/scripts/modem/sxmo_modemdial.sh @@ -18,7 +18,12 @@ modem_n() { dialmenu() { CONTACTS="$(sxmo_contacts.sh)" NUMBER="$( - printf %b "Close Menu\n$CONTACTS" | + printf %b "Close Menu\nMore contacts\n$CONTACTS" | + grep . | + sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20 -i + )" + echo "$NUMBER" | grep "More contacts" && NUMBER="$( + printf %b "Close Menu\n$(sxmo_contacts.sh --all)" | grep . | sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20 -i )" @@ -29,8 +34,8 @@ dialmenu() { echo "Attempting to dial: $NUMBER" >&2 CALLID="$( - mmcli -m "$(modem_n)" --voice-create-call "number=$NUMBER" | - grep -Eo "Call/[0-9]+" | + mmcli -m "$(modem_n)" --voice-create-call "number=$NUMBER" | + grep -Eo "Call/[0-9]+" | grep -oE "[0-9]+" )" echo "Starting call with CALLID: $CALLID" >&2 diff --git a/scripts/modem/sxmo_modemtext.sh b/scripts/modem/sxmo_modemtext.sh index cb9bf46..08287fc 100755 --- a/scripts/modem/sxmo_modemtext.sh +++ b/scripts/modem/sxmo_modemtext.sh @@ -38,13 +38,20 @@ choosenumbermenu() { # Prompt for number NUMBER="$( - printf %b "\nCancel\n$(sxmo_contacts.sh)" | + printf %b "\nCancel\nMore contacts\n$(sxmo_contacts.sh)" | awk NF | menu sxmo_dmenu_with_kb.sh -p "Number" -fn "Terminus-20" -l 10 -c -i | cut -d: -f1 | tr -d -- '- ' )" - echo "$NUMBER" | grep -E "^Cancel$" && exit 1 + echo "$NUMBER" | grep -qE "^Morecontacts$" && NUMBER="$( #joined words without space is not a bug + printf %b "\nCancel\n$(sxmo_contacts.sh --all)" | + grep . | + sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20 -i + cut -d: -f1 | + tr -d -- '- ' + )" + echo "$NUMBER" | grep -qE "^Cancel$" && exit 1 echo "$NUMBER" | grep -qE '^[+0-9]+$' || err "That doesn't seem like a valid number" echo "$NUMBER" }