From 2c47c5e55f0620a287c19a7a6ca6664d97740cb5 Mon Sep 17 00:00:00 2001 From: Stacy Harper Date: Sat, 15 May 2021 18:42:00 +0200 Subject: [PATCH] List unknown numbers when adding contact Signed-off-by: Stacy Harper Signed-off-by: Maarten van Gompel --- scripts/core/sxmo_contactmenu.sh | 8 ++++---- scripts/core/sxmo_contacts.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/core/sxmo_contactmenu.sh b/scripts/core/sxmo_contactmenu.sh index 5646db7..1c68875 100755 --- a/scripts/core/sxmo_contactmenu.sh +++ b/scripts/core/sxmo_contactmenu.sh @@ -18,7 +18,7 @@ newcontact() { name="$(echo | sxmo_dmenu_with_kb.sh -c -l 2 -p "$icon_usr Name")" number= while [ -z "$number" ]; do - number="$(echo | sxmo_dmenu_with_kb.sh -c -l 2 -p "$icon_phl Number")" + number="$(sxmo_contacts.sh --unknown | sxmo_dmenu_with_kb.sh -c -l 10 -p "$icon_phl Number")" number="$(valid_number "$number")" done @@ -49,14 +49,14 @@ editcontactnumber() { oldnumber="$(echo "$1" | cut -d" " -f1)" oldname="$(echo "$1" | cut -d" " -f2)" - ENTRIES="$(printf %b "Old number: $oldnumber")" + ENTRIES="$(sxmo_contacts.sh --unknown | xargs -0 printf "%b (Old number)\n%b" "$oldnumber")" PICKED= # already used var name while [ -z "$PICKED" ]; do PICKED="$( echo "$ENTRIES" | - sxmo_dmenu_with_kb.sh -c -l 3 -p "$icon_edt Edit Contact" + sxmo_dmenu_with_kb.sh -c -l 10 -p "$icon_edt Edit Contact" )" - if echo "$PICKED" | grep -q "^Old number: "; then + if echo "$PICKED" | grep -q "(Old number)$"; then editcontact "$1" return fi diff --git a/scripts/core/sxmo_contacts.sh b/scripts/core/sxmo_contacts.sh index 886dc22..b01cdf1 100755 --- a/scripts/core/sxmo_contacts.sh +++ b/scripts/core/sxmo_contacts.sh @@ -40,8 +40,17 @@ all_contacts() { }' "$CONTACTSFILE" | sort -f -k 2 } +unknown_contacts() { + contacts \ + | grep "Unknown Number$" \ + | cut -d: -f1 \ + | grep "^+[0-9]\{9,14\}$" +} + if [ "$1" = "--all" ]; then all_contacts +elif [ "$1" = "--unknown" ]; then + unknown_contacts else contacts fi