add manual phone input

This commit is contained in:
Simon Vieille 2019-08-21 09:56:34 +02:00
parent 6fc428e9bb
commit 5a0c732391
Signed by: deblan
GPG Key ID: 03383D15A1D31745
2 changed files with 24 additions and 18 deletions

View File

@ -6,13 +6,14 @@ Send SMS using kdeconnect.
```bash
$ git clone https://gitnet.fr/deblan/sms-sender.git
$ cd sms-sender
$ FILE=/path/to/contacts.vcf DEVICE=XXXXXXXXXXXXXXXX ./send-sms
$ export FILE=/path/to/contacts.vcf # not required if you manually fill the number
$ export DEVICE=XXXXXXXXXXXXXXXX # @see kdeconnect-cli -l
$ ./send-sms
```
Requirements
------------
* SH
* whiptail
* kdeconnect
* kdeconnect-cli
* vim

View File

@ -6,34 +6,39 @@ SCRIPT_PATH="$(dirname "$SCRIPT_NAME")"
cd "$SCRIPT_PATH"
usage() {
printf " Usage:\\n"
printf " FILE=/path/to/contacts.vcf DEVICE=XXXXXXXXXXXXXXXX %s\\n" "$0"
printf " Usage:\\n\\n"
printf " [FILE=/path/to/contacts.vcf] DEVICE=XXXXXXXXXXXXXXXX %s\\n" "$0"
}
if [ -z "$FILE" ] || [ -z "$DEVICE" ]; then
if [ -z "$DEVICE" ]; then
usage
exit 0
fi
SEARCH="$(whiptail --title "Filtrer les destinataires" --inputbox "Laissez vide pour tout voir" 8 50 3>&1 1>&2 2>&3)"
if [ -n "$FILE" ]; then
SEARCH="$(whiptail --title "Filtrer les destinataires" --inputbox "Laissez vide pour tout voir" 8 50 3>&1 1>&2 2>&3)"
COMMAND="whiptail --title \"Contacts\" --menu \"Choisir un destinataire\" 25 65 16"
COMMAND="whiptail --title \"Contacts\" --menu \"Choisir un destinataire\" 25 65 16"
COMMAND="$COMMAND $(FILE="$FILE" ./extract-contacts | sort | while read CONTACT; do
VALUE="$(echo "$CONTACT" | cut -d\| -f2 | sed 's/"//g')"
LABEL="$(echo "$CONTACT" | cut -d\| -f1 | sed 's/"//g')"
COMMAND="$COMMAND $(FILE="$FILE" ./extract-contacts | sort | while read CONTACT; do
VALUE="$(echo "$CONTACT" | cut -d\| -f2 | sed 's/"//g')"
LABEL="$(echo "$CONTACT" | cut -d\| -f1 | sed 's/"//g')"
if [ -n "$SEARCH" ]; then
if [ -n "$(echo "$LABEL" | grep -i "$SEARCH")" ]; then
if [ -n "$SEARCH" ]; then
if [ -n "$(echo "$LABEL" | grep -i "$SEARCH")" ]; then
printf " \"%s\" \"%s\"" "$VALUE" "$LABEL"
fi
else
printf " \"%s\" \"%s\"" "$VALUE" "$LABEL"
fi
else
printf " \"%s\" \"%s\"" "$VALUE" "$LABEL"
fi
done)"
done)"
PHONE="$(eval "$COMMAND 3>&1 1>&2 2>&3")"
else
PHONE="$(whiptail --title "Saisir le numéro" --inputbox "" 8 50 3>&1 1>&2 2>&3)"
fi
PHONE="$(eval "$COMMAND 3>&1 1>&2 2>&3")"
if [ -n "$PHONE" ]; then
TMP_FILE="/tmp/send-sms-$(tr -dc "qwertQWERTasdfgASDFGzxcvbZXCVB" < /dev/urandom | head -c 16)"