|
|
@ -1,7 +1,7 @@ |
|
|
|
#!/usr/bin/env sh |
|
|
|
#!/usr/bin/env sh |
|
|
|
LOGDIR="$XDG_CONFIG_HOME"/sxmo/modem |
|
|
|
LOGDIR="$XDG_CONFIG_HOME"/sxmo/modem |
|
|
|
TERMMODE=$([ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && echo "true") |
|
|
|
TERMMODE=$([ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && echo "true") |
|
|
|
POSTPONE_DIR="$XDG_CONFIG_HOME/sxmo/modem/postponed" |
|
|
|
DRAFT_DIR="$XDG_CONFIG_HOME/sxmo/modem/draft" |
|
|
|
|
|
|
|
|
|
|
|
menu() { |
|
|
|
menu() { |
|
|
|
if [ "$TERMMODE" != "true" ]; then |
|
|
|
if [ "$TERMMODE" != "true" ]; then |
|
|
@ -47,7 +47,7 @@ choosenumbermenu() { |
|
|
|
echo "$NUMBER" | grep -qE "^Morecontacts$" && NUMBER="$( #joined words without space is not a bug |
|
|
|
echo "$NUMBER" | grep -qE "^Morecontacts$" && NUMBER="$( #joined words without space is not a bug |
|
|
|
printf %b "\nCancel\n$(sxmo_contacts.sh --all)" | |
|
|
|
printf %b "\nCancel\n$(sxmo_contacts.sh --all)" | |
|
|
|
grep . | |
|
|
|
grep . | |
|
|
|
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20 -i |
|
|
|
menu sxmo_dmenu_with_kb.sh -l 10 -p "Number" -c -fn Terminus-20 -i | |
|
|
|
cut -d: -f1 | |
|
|
|
cut -d: -f1 | |
|
|
|
tr -d -- '- ' |
|
|
|
tr -d -- '- ' |
|
|
|
)" |
|
|
|
)" |
|
|
@ -69,33 +69,33 @@ sendtextmenu() { |
|
|
|
while true |
|
|
|
while true |
|
|
|
do |
|
|
|
do |
|
|
|
CONFIRM="$( |
|
|
|
CONFIRM="$( |
|
|
|
printf %b "Edit Message ($(echo "$TEXT" | head -n1))\nSend to → $NUMBER\nPostpone\nCancel" | |
|
|
|
printf %b "Edit Message ($(echo "$TEXT" | head -n1))\nSend to → $NUMBER\nSave as Draft\nCancel" | |
|
|
|
menu dmenu -c -idx 1 -p "Confirm" -fn "Terminus-20" -l 10 |
|
|
|
menu dmenu -c -idx 1 -p "Confirm" -fn "Terminus-20" -l 10 |
|
|
|
)" |
|
|
|
)" |
|
|
|
echo "$CONFIRM" | grep -E "^Send" && (echo "$TEXT" | sxmo_modemsendsms.sh "$NUMBER" -) && exit 0 |
|
|
|
echo "$CONFIRM" | grep -E "^Send" && (echo "$TEXT" | sxmo_modemsendsms.sh "$NUMBER" -) && exit 0 |
|
|
|
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
|
|
|
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
|
|
|
echo "$CONFIRM" | grep -E "^Edit Message" && TEXT="$(editmsg "$NUMBER" "$TEXT")" |
|
|
|
echo "$CONFIRM" | grep -E "^Edit Message" && TEXT="$(editmsg "$NUMBER" "$TEXT")" |
|
|
|
echo "$CONFIRM" | grep -E "^Postpone$" && err "Postponed to $(postpone "$NUMBER" "$TEXT")" |
|
|
|
echo "$CONFIRM" | grep -E "^Save as Draft$" && err "Draft saved to $(draft "$NUMBER" "$TEXT")" |
|
|
|
done |
|
|
|
done |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
postpone() { |
|
|
|
draft() { |
|
|
|
NUMBER="$1" |
|
|
|
NUMBER="$1" |
|
|
|
TEXT="$2" |
|
|
|
TEXT="$2" |
|
|
|
mkdir -p "$POSTPONE_DIR" |
|
|
|
mkdir -p "$DRAFT_DIR" |
|
|
|
POSTPONE_FILE="$NUMBER-$(date +'%Y-%m-%d_%H-%m-%S')" |
|
|
|
DRAFT_FILE="$NUMBER-$(date +'%Y-%m-%d_%H-%m-%S')" |
|
|
|
echo "$NUMBER" > "$POSTPONE_DIR/$POSTPONE_FILE" |
|
|
|
echo "$NUMBER" > "$DRAFT_DIR/$DRAFT_FILE" |
|
|
|
echo "$TEXT" >> "$POSTPONE_DIR/$POSTPONE_FILE" |
|
|
|
echo "$TEXT" >> "$DRAFT_DIR/$DRAFT_FILE" |
|
|
|
echo "$POSTPONE_FILE" |
|
|
|
echo "$DRAFT_FILE" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sendpostponedtextmenu() { |
|
|
|
senddrafttextmenu() { |
|
|
|
CONFIRM="$( |
|
|
|
CONFIRM="$( |
|
|
|
printf %b "Cancel\n$(ls "$POSTPONE_DIR")" | |
|
|
|
printf %b "Cancel\n$(ls "$DRAFT_DIR")" | |
|
|
|
menu sxmo_dmenu_with_kb.sh -p "Postponed Message" -fn "Terminus-20" -l 10 -c -i |
|
|
|
menu sxmo_dmenu_with_kb.sh -p "Draft Message" -fn "Terminus-20" -l 10 -c -i |
|
|
|
)" |
|
|
|
)" |
|
|
|
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
|
|
|
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
|
|
|
FILE="$POSTPONE_DIR/$CONFIRM" |
|
|
|
FILE="$DRAFT_DIR/$CONFIRM" |
|
|
|
NUMBER="$(head -n1 "$FILE")" |
|
|
|
NUMBER="$(head -n1 "$FILE")" |
|
|
|
TEXT="$(tail -n +2 "$FILE")" |
|
|
|
TEXT="$(tail -n +2 "$FILE")" |
|
|
|
rm "$FILE" |
|
|
|
rm "$FILE" |
|
|
@ -113,7 +113,7 @@ tailtextlog() { |
|
|
|
main() { |
|
|
|
main() { |
|
|
|
# E.g. only display logfiles for directories that exist and join w contact name |
|
|
|
# E.g. only display logfiles for directories that exist and join w contact name |
|
|
|
ENTRIES="$( |
|
|
|
ENTRIES="$( |
|
|
|
printf %b "Close Menu\nSend a Text\nSend a Postponed Text\n"; |
|
|
|
printf %b "Close Menu\nSend a Text$( [ "$(ls -A "$DRAFT_DIR")" ] && printf %b "\nSend a Draft Text")\n"; |
|
|
|
sxmo_contacts.sh | while read -r CONTACT; do |
|
|
|
sxmo_contacts.sh | while read -r CONTACT; do |
|
|
|
[ -d "$LOGDIR"/"$(printf %b "$CONTACT" | cut -d: -f1)" ] || continue |
|
|
|
[ -d "$LOGDIR"/"$(printf %b "$CONTACT" | cut -d: -f1)" ] || continue |
|
|
|
printf %b "$CONTACT" | xargs -IL echo "L logfile" |
|
|
|
printf %b "$CONTACT" | xargs -IL echo "L logfile" |
|
|
@ -122,7 +122,7 @@ main() { |
|
|
|
CONTACTIDANDNUM="$(printf %b "$ENTRIES" | menu dmenu -p Texts -c -fn Terminus-20 -l 10 -i)" |
|
|
|
CONTACTIDANDNUM="$(printf %b "$ENTRIES" | menu dmenu -p Texts -c -fn Terminus-20 -l 10 -i)" |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Close Menu" && exit 1 |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Close Menu" && exit 1 |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Send a Text" && sendnewtextmenu && exit 1 |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Send a Text" && sendnewtextmenu && exit 1 |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Send a Postponed Text" && sendpostponedtextmenu && exit 1 |
|
|
|
echo "$CONTACTIDANDNUM" | grep "Send a Draft Text" && senddrafttextmenu && exit 1 |
|
|
|
tailtextlog "$(echo "$CONTACTIDANDNUM" | cut -d: -f1)" |
|
|
|
tailtextlog "$(echo "$CONTACTIDANDNUM" | cut -d: -f1)" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|