Sane message when terminating call with unknown number and more verbose output to stderr from modem scripts

master
Maarten van Gompel 4 years ago
parent fc051045c9
commit 4a90d86f56
  1. 22
      scripts/modem/sxmo_modemcall.sh
  2. 1
      scripts/modem/sxmo_modemdial.sh
  3. 7
      scripts/modem/sxmo_modemmonitor.sh
  4. 3
      scripts/modem/sxmo_modemtext.sh

@ -19,6 +19,7 @@ fatalerr() {
mmcli -m "$(modem_n)" --voice-delete-call "$CALLID" mmcli -m "$(modem_n)" --voice-delete-call "$CALLID"
done done
alsactl --file /usr/share/sxmo/alsa/default_alsa_sound.conf restore alsactl --file /usr/share/sxmo/alsa/default_alsa_sound.conf restore
echo "$1">&2
notify-send "$1" notify-send "$1"
setsid -f sh -c 'sleep 2; sxmo_statusbarupdate.sh' setsid -f sh -c 'sleep 2; sxmo_statusbarupdate.sh'
kill -9 0 kill -9 0
@ -32,7 +33,7 @@ gracefulexit() {
modem_cmd_errcheck() { modem_cmd_errcheck() {
RES="$(mmcli "$@" 2>&1)" RES="$(mmcli "$@" 2>&1)"
OK="$?" OK="$?"
echo "Command: mmcli $*" echo "Command: mmcli $*">&2
if [ "$OK" != 0 ]; then fatalerr "Problem executing mmcli command!\n$RES"; fi if [ "$OK" != 0 ]; then fatalerr "Problem executing mmcli command!\n$RES"; fi
echo "$RES" echo "$RES"
} }
@ -75,7 +76,7 @@ toggleflagset() {
acceptcall() { acceptcall() {
CALLID="$1" CALLID="$1"
echo "Attempting to initialize CALLID $CALLID" echo "Attempting to initialize CALLID $CALLID">&2
DIRECTION="$( DIRECTION="$(
mmcli --voice-status -o "$CALLID" -K | mmcli --voice-status -o "$CALLID" -K |
grep call.properties.direction | grep call.properties.direction |
@ -85,12 +86,15 @@ acceptcall() {
if [ "$DIRECTION" = "outgoing" ]; then if [ "$DIRECTION" = "outgoing" ]; then
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --start modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --start
log_event "call_start" "$CALLID" log_event "call_start" "$CALLID"
echo "Started call $CALLID">&2
elif [ "$DIRECTION" = "incoming" ]; then elif [ "$DIRECTION" = "incoming" ]; then
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/pickup" ]; then if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/pickup" ]; then
echo "Invoking pickup hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/pickup" & "$XDG_CONFIG_HOME/sxmo/hooks/pickup" &
fi fi
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --accept modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --accept
log_event "call_pickup" "$CALLID" log_event "call_pickup" "$CALLID"
echo "Picked up call $CALLID">&2
else else
fatalerr "Couldn't initialize call with callid <$CALLID>; unknown direction <$DIRECTION>" fatalerr "Couldn't initialize call with callid <$CALLID>; unknown direction <$DIRECTION>"
fi fi
@ -132,15 +136,19 @@ incallmonitor() {
while true; do while true; do
sxmo_statusbarupdate.sh sxmo_statusbarupdate.sh
if mmcli -m "$(modem_n)" -K -o "$CALLID" | grep -E "^call.properties.state.+terminated"; then if mmcli -m "$(modem_n)" -K -o "$CALLID" | grep -E "^call.properties.state.+terminated"; then
fatalerr "Call with $NUMBER terminated" if [ "$NUMBER" = "--" ]; then
fatalerr "Call with unknown number terminated"
else
fatalerr "Call with $NUMBER terminated"
fi
fi fi
echo "Call still in progress" echo "Call still in progress">&2
sleep 3 sleep 3
done done
} }
incallmenuloop() { incallmenuloop() {
echo "Current flags are $FLAGS" echo "Current flags are $FLAGS">&2
CHOICES=" CHOICES="
$([ "$WINDOWIFIED" = 0 ] && echo Windowify || echo Unwindowify) ^ togglewindowify $([ "$WINDOWIFIED" = 0 ] && echo Windowify || echo Unwindowify) ^ togglewindowify
$([ "$WINDOWIFIED" = 0 ] && echo 'Screenlock ^ togglewindowify; sxmo_screenlock &') $([ "$WINDOWIFIED" = 0 ] && echo 'Screenlock ^ togglewindowify; sxmo_screenlock &')
@ -165,11 +173,11 @@ incallmenuloop() {
dmenu -idx $DMENUIDX -l 14 "$([ "$WINDOWIFIED" = 0 ] && echo "-c" || echo "-wm")" -fn "Terminus-30" -p "$NUMBER" | dmenu -idx $DMENUIDX -l 14 "$([ "$WINDOWIFIED" = 0 ] && echo "-c" || echo "-wm")" -fn "Terminus-30" -p "$NUMBER" |
( (
PICKED="$(cat)"; PICKED="$(cat)";
echo "Picked is $PICKED" echo "Picked is $PICKED">&2
echo "$PICKED" | grep -Ev "." echo "$PICKED" | grep -Ev "."
CMD=$(echo "$CHOICES" | grep "$PICKED" | cut -d'^' -f2) CMD=$(echo "$CHOICES" | grep "$PICKED" | cut -d'^' -f2)
DMENUIDX=$(echo "$(echo "$CHOICES" | grep -n "$PICKED" | cut -d ':' -f1)" - 1 | bc) DMENUIDX=$(echo "$(echo "$CHOICES" | grep -n "$PICKED" | cut -d ':' -f1)" - 1 | bc)
echo "Eval in call context: $CMD" echo "Eval in call context: $CMD">&2
eval "$CMD" eval "$CMD"
incallmenuloop incallmenuloop
) & wait # E.g. bg & wait to allow for SIGINT propogation ) & wait # E.g. bg & wait to allow for SIGINT propogation

@ -4,6 +4,7 @@ trap "gracefulexit" INT TERM
fatalerr() { fatalerr() {
# E.g. hangup all calls, switch back to default audio, notify user, and die # E.g. hangup all calls, switch back to default audio, notify user, and die
mmcli -m "$(mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2)" --voice-hangup-all mmcli -m "$(mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2)" --voice-hangup-all
echo "$1" >&2
notify-send "$1" notify-send "$1"
(sleep 0.5; sxmo_statusbarupdate.sh) & (sleep 0.5; sxmo_statusbarupdate.sh) &
kill -9 0 kill -9 0

@ -4,12 +4,13 @@ NOTIFDIR="$XDG_DATA_HOME"/sxmo/notifications
trap "gracefulexit" INT TERM trap "gracefulexit" INT TERM
err() { err() {
echo "$1">&2
notify-send "$1" notify-send "$1"
gracefulexit gracefulexit
} }
gracefulexit() { gracefulexit() {
echo "gracefully exiting $0!" echo "gracefully exiting $0!">&2
kill -9 0 kill -9 0
} }
@ -71,6 +72,7 @@ checkforincomingcalls() {
INCOMINGNUMBER=$(lookupnumberfromcallid "$VOICECALLID") INCOMINGNUMBER=$(lookupnumberfromcallid "$VOICECALLID")
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
echo "Invoking ring hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/ring" "$(sxmo_contacts.sh | grep -E "^${INCOMINGNUMBER//+/\\+}:")" & "$XDG_CONFIG_HOME/sxmo/hooks/ring" "$(sxmo_contacts.sh | grep -E "^${INCOMINGNUMBER//+/\\+}:")" &
else else
sxmo_vibratepine 2500 & sxmo_vibratepine 2500 &
@ -86,7 +88,7 @@ checkforincomingcalls() {
none \ none \
"Pickup - $(sxmo_contacts.sh | grep -E "^${INCOMINGNUMBER//+/\\+}:")" & "Pickup - $(sxmo_contacts.sh | grep -E "^${INCOMINGNUMBER//+/\\+}:")" &
echo "Number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)" echo "Call from number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)">&2
} }
checkfornewtexts() { checkfornewtexts() {
@ -109,6 +111,7 @@ checkfornewtexts() {
TIME="$(echo "$TEXTDATA" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')" TIME="$(echo "$TEXTDATA" | grep sms.properties.timestamp | sed -E 's/^sms\.properties\.timestamp\s+:\s+//')"
mkdir -p "$LOGDIR/$NUM" mkdir -p "$LOGDIR/$NUM"
echo "Text from number: $NUM (TEXTID: $TEXTID)">&2
printf %b "Received from $NUM at $TIME:\n$TEXT\n\n" >> "$LOGDIR/$NUM/sms.txt" printf %b "Received from $NUM at $TIME:\n$TEXT\n\n" >> "$LOGDIR/$NUM/sms.txt"
printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$LOGDIR/modemlog.tsv" printf %b "$TIME\trecv_txt\t$NUM\t${#TEXT} chars\n" >> "$LOGDIR/modemlog.tsv"
mmcli -m "$(modem_n)" --messaging-delete-sms="$TEXTID" mmcli -m "$(modem_n)" --messaging-delete-sms="$TEXTID"

@ -12,6 +12,7 @@ menu() {
} }
err() { err() {
echo "$1">&2
echo "$1" | menu dmenu -fn Terminus-20 -c -l 10 echo "$1" | menu dmenu -fn Terminus-20 -c -l 10
kill $$ kill $$
} }
@ -72,7 +73,7 @@ sendtextmenu() {
printf %b "Edit Message ($(echo "$TEXT" | head -n1))\nSend to → $NUMBER\nSave as Draft\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" -) && echo "Sent text to $NUMBER">&2 && 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 "^Save as Draft$" && err "Draft saved to $(draft "$NUMBER" "$TEXT")" echo "$CONFIRM" | grep -E "^Save as Draft$" && err "Draft saved to $(draft "$NUMBER" "$TEXT")"

Loading…
Cancel
Save