From f2fc6a406e27080ce4ebd1b663891a4d5ed19a59 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 8 Nov 2020 11:56:21 -0600 Subject: [PATCH] Missed call rework: Use dbus to check for missed calls & properly delete pickup Use dbus to monitor for missed calls. Missed calls used to work but had a regression due to the work to make text/calls used dbus. This adds the proper dbus hook for missed calls as well and also changes the incoming call notification to allow for multiple incoming calls (theoretically). Tested for a single caller and transitioning the pickup notification into a missed call notification and all is working good. --- scripts/modem/sxmo_modemmonitor.sh | 20 +++++++++++++++++--- scripts/modem/sxmo_modemmonitortoggle.sh | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/modem/sxmo_modemmonitor.sh b/scripts/modem/sxmo_modemmonitor.sh index 7397a2b..aa0e48c 100755 --- a/scripts/modem/sxmo_modemmonitor.sh +++ b/scripts/modem/sxmo_modemmonitor.sh @@ -41,6 +41,8 @@ checkformissedcalls() { ); do MISSEDNUMBER="$(lookupnumberfromcallid "$MISSEDCALLID")" mmcli -m "$(modem_n)" --voice-delete-call "$MISSEDCALLID" + rm -f "$NOTIFDIR/incomingcall_${MISSEDCALLID}_notification" + TIME="$(date --iso-8601=seconds)" mkdir -p "$LOGDIR" @@ -62,7 +64,6 @@ checkforincomingcalls() { grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )" - echo "$VOICECALLID" | grep -v . && rm -f "$NOTIFDIR/incomingcall" && return # Determine the incoming phone number echo "Incoming Call:" @@ -79,7 +80,7 @@ checkforincomingcalls() { printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$LOGDIR/modemlog.tsv" sxmo_notificationwrite.sh \ - "$NOTIFDIR/incomingcall" \ + "$NOTIFDIR/incomingcall_${VOICECALLID}_notification" \ "sxmo_modemcall.sh pickup $VOICECALLID" \ none \ "Pickup - $(sxmo_contacts.sh | grep -E "^\\$INCOMINGNUMBER")" & @@ -125,15 +126,28 @@ checkfornewtexts() { mainloop() { checkformissedcalls + checkforincomingcalls + checkfornewtexts + + # Monitor for incoming calls dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" | \ while read -r; do checkforincomingcalls - checkformissedcalls done & + + # Monitor for incoming texts dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" | \ while read -r; do checkfornewtexts done & + + # Monitor for missed calls + dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" | \ + while read -r; do + checkformissedcalls + done & + + wait wait wait } diff --git a/scripts/modem/sxmo_modemmonitortoggle.sh b/scripts/modem/sxmo_modemmonitortoggle.sh index e90f002..39c2f8c 100755 --- a/scripts/modem/sxmo_modemmonitortoggle.sh +++ b/scripts/modem/sxmo_modemmonitortoggle.sh @@ -5,7 +5,8 @@ else sxmo_modemmonitor.sh & fi -rm /tmp/sxmo_incomingcall +NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications +rm $NOTIFDIR/incomingcall* # E.g. wait until process killed or started -- maybe there's a better way.. sleep 1