Initial work on modem functionality

Including, checking for incoming calls, missed calls, sms and the start
of a dialer using rofi
This commit is contained in:
Jonathan Hodgson 2021-03-02 18:35:57 +00:00
parent afb6634bec
commit 1ab519531c
6 changed files with 259 additions and 55 deletions

View file

@ -1,19 +1,15 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/common"
# This is largely borrowed from:
# https://git.sr.ht/~mil/sxmo-utils/tree/master/item/scripts/modem/sxmo_modemmonitor.sh
# This is where sms messages will be stored
SMS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/SMS/"
die(){
echo "$@" > /dev/stderr
rm "$FILE"
exit 1
}
usage(){
echo "checkSMS [options] [message|-]"
echo "checkSMS [options]"
echo "Options:"
echo " -h|--help Display this help text"
echo " -m|--modem Specify a modem"
@ -21,57 +17,15 @@ usage(){
}
trimWhitespace(){
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
}
mkdir -p "$SMS_DIR"
dryrun="false"
edit="false"
# Assume we want the first modem
# can be overwritten by the -m option
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into
# --foo bar
optstring=h
unset options
while (($#)); do
case $1 in
# If option is of type -ab
-[!-]?*)
# Loop over each character starting with the second
for ((i=1; i < ${#1}; i++)); do
c=${1:i:1}
# Add current char to options
options+=("-$c")
# If option takes a required argument, and it's not the last char make
# the rest of the string its argument
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then
options+=("${1:i+1}")
break
fi
done
;;
# If option is of type --foo=bar
--?*=*) options+=("${1%%=*}" "${1#*=}") ;;
# add --endopts for --
--) options+=(--endopts) ;;
# Otherwise, nothing special
*) options+=("$1") ;;
esac
shift
done
set -- "${options[@]}"
unset options
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
@ -88,9 +42,9 @@ done
ids="$( mmcli -m "$modem" --messaging-list-sms |
grep -Eo '/SMS/[0-9]+ \(received\)' | grep -Eo '[0-9]+' )"
count="$(echo "$ids" | wc -l)"
count="$(echo "$ids" | deleteEmptyLines | wc -l)"
[ "$count" -eq 0 ] && return
[ "$count" -eq 0 ] && exit
echo "$ids" | while read -r id; do
# Get the details of the message