From 11bd42c0aeed2157a3fe7f14ebacf9bf542b94da Mon Sep 17 00:00:00 2001 From: Stacy Harper Date: Tue, 7 Dec 2021 17:10:40 +0100 Subject: [PATCH] Order contact attachments by date by default This make it easy to open the last receive mms attachment by example. --- configs/default_hooks/contextmenu | 2 +- scripts/appscripts/sxmo_files.sh | 33 ++++++++++++++++++++++++++----- scripts/modem/sxmo_modemtext.sh | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/configs/default_hooks/contextmenu b/configs/default_hooks/contextmenu index 9d4ae66..d13a06f 100644 --- a/configs/default_hooks/contextmenu +++ b/configs/default_hooks/contextmenu @@ -335,7 +335,7 @@ case "$WMCLASS" in $icon_msg Conversation ^ 0 ^ sxmo_terminal.sh sxmo_modemtext.sh conversationloop $number $icon_msg Reply ^ 0 ^ sxmo_modemtext.sh sendtextmenu $number $icon_phn Call ^ 0 ^ sxmo_modemdial.sh $number - $([ -d "$LOGDIR/$number/attachments" ] && echo "$icon_att View Attachments ^ 1 ^ sxmo_files.sh $LOGDIR/$number/attachments") + $([ -d "$LOGDIR/$number/attachments" ] && echo "$icon_att View Attachments ^ 1 ^ sxmo_files.sh $LOGDIR/$number/attachments --date-sort") $(sxmo_contacts.sh --name "$number" | grep -q '???' && echo "$icon_usr Add to contacts ^ 1 ^ sxmo_contactmenu.sh newcontact $number") $icon_aru Scroll up ^ 1 ^ sxmo_type -M Shift -M Ctrl b $icon_ard Scroll down ^ 1 ^ sxmo_type -M Shift -M Ctrl f diff --git a/scripts/appscripts/sxmo_files.sh b/scripts/appscripts/sxmo_files.sh index 62dd72d..7ae36b4 100755 --- a/scripts/appscripts/sxmo_files.sh +++ b/scripts/appscripts/sxmo_files.sh @@ -6,15 +6,38 @@ set -e -DIR="$1" -[ -z "$DIR" ] && DIR="$HOME" -cd "$DIR" || exit 1 - -[ -n "$2" ] && SELECTONLY=1 +usage() { + printf "%s [--date-sort] [--reverse-sort] [--select-only] [-h help]\n" \ + "$(basename "$0")" + exit 1 +} +DIR="$HOME" SORT= REVERSE= +while [ -n "$1" ]; do + case "$1" in + --select-only) + SELECTONLY=1 + ;; + --date-sort) + SORT="--sort=t" + ;; + --reverse-sort) + REVERSE="-r" + ;; + -h) + usage + ;; + *) + DIR="$1" + esac + shift +done + +cd "$DIR" + sort_loop() { CHOICES="$([ -z "$SORT" ] && printf "date" || printf "name")\n$([ -z "$REVERSE" ] && printf "desc" || printf "asc")\n" diff --git a/scripts/modem/sxmo_modemtext.sh b/scripts/modem/sxmo_modemtext.sh index a5e3ebb..5d91ad8 100755 --- a/scripts/modem/sxmo_modemtext.sh +++ b/scripts/modem/sxmo_modemtext.sh @@ -122,7 +122,7 @@ sendtextmenu() { sendtextmenu "$NUMBER" ;; *"Add Attachment") - ATTACHMENT="$(sxmo_files.sh "$HOME" selectonly)" + ATTACHMENT="$(sxmo_files.sh "$HOME" --select-only)" if [ -f "$ATTACHMENT" ]; then printf "%s\n" "$ATTACHMENT" >> "$LOGDIR/$NUMBER/draft.attachments.txt" fi