Create a new notification when there is a missed call
This commit is contained in:
parent
5f8aad0386
commit
17fb103ee3
1 changed files with 44 additions and 27 deletions
|
@ -20,6 +20,44 @@ modem_n() {
|
||||||
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
|
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lookupnumberfromcallid() {
|
||||||
|
VOICECALLID=$1
|
||||||
|
mmcli -m "$(modem_n)" --voice-list-calls -o "$VOICECALLID" -K |
|
||||||
|
grep call.properties.number |
|
||||||
|
cut -d ':' -f 2 |
|
||||||
|
tr -d ' +'
|
||||||
|
}
|
||||||
|
|
||||||
|
checkformissedcalls() {
|
||||||
|
if pgrep -vf sxmo_modemcall.sh; then
|
||||||
|
# Add a notification for every missed call
|
||||||
|
# Note sxmo_modemcall.sh cleanups/delete the callid from the modem; so
|
||||||
|
# effectivly any incoming call thats terminated here is a missed call!
|
||||||
|
for MISSEDCALLID in $(
|
||||||
|
mmcli -m "$(modem_n)" --voice-list-calls |
|
||||||
|
grep incoming |
|
||||||
|
grep terminated |
|
||||||
|
grep -oE "Call\/[0-9]+" |
|
||||||
|
cut -d'/' -f2
|
||||||
|
); do
|
||||||
|
MISSEDNUMBER="$(lookupnumberfromcallid $MISSEDCALLID)"
|
||||||
|
mmcli -m "$(modem_n)" --voice-delete-call "$MISSEDCALLID"
|
||||||
|
|
||||||
|
TIME="$(date --iso-8601=seconds)"
|
||||||
|
mkdir -p "$LOGDIR"
|
||||||
|
printf %b "$TIME\tcall_missed\t$MISSEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
|
||||||
|
|
||||||
|
CONTACT="$(sxmo_contacts.sh | grep -E "^$MISSEDNUMBER")"
|
||||||
|
RUNCOMMAND=""
|
||||||
|
sxmo_notificationwrite.sh \
|
||||||
|
random \
|
||||||
|
"st -f Terminus-20 -e sh -c \"echo 'Missed call from $CONTACT at $(date)' && read\"" \
|
||||||
|
none \
|
||||||
|
"Missed call - $CONTACT"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
checkforincomingcalls() {
|
checkforincomingcalls() {
|
||||||
VOICECALLID="$(
|
VOICECALLID="$(
|
||||||
mmcli -m "$(modem_n)" --voice-list-calls -a |
|
mmcli -m "$(modem_n)" --voice-list-calls -a |
|
||||||
|
@ -28,38 +66,16 @@ checkforincomingcalls() {
|
||||||
)"
|
)"
|
||||||
echo "$VOICECALLID" | grep -v . && rm -f "$NOTIFDIR/incomingcall" && return
|
echo "$VOICECALLID" | grep -v . && rm -f "$NOTIFDIR/incomingcall" && return
|
||||||
|
|
||||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
|
|
||||||
"$XDG_CONFIG_HOME/sxmo/hooks/ring"
|
|
||||||
else
|
|
||||||
sxmo_vibratepine 2000 &
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Delete all previous calls which have been terminated calls
|
|
||||||
for CALLID in $(
|
|
||||||
mmcli -m "$(modem_n)" --voice-list-calls |
|
|
||||||
grep terminated |
|
|
||||||
grep -oE "Call\/[0-9]+" |
|
|
||||||
cut -d'/' -f2
|
|
||||||
); do
|
|
||||||
mmcli -m "$(modem_n)" --voice-delete-call "$CALLID"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Determine the incoming phone number
|
# Determine the incoming phone number
|
||||||
echo "Incoming Call:"
|
echo "Incoming Call:"
|
||||||
INCOMINGNUMBER=$(
|
INCOMINGNUMBER=$(lookupnumberfromcallid "$VOICECALLID")
|
||||||
mmcli -m "$(modem_n)" --voice-list-calls -o "$VOICECALLID" -K |
|
|
||||||
grep call.properties.number |
|
|
||||||
cut -d ':' -f 2 |
|
|
||||||
tr -d ' +'
|
|
||||||
)
|
|
||||||
|
|
||||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
|
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
|
||||||
"$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 2000 &
|
sxmo_vibratepine 2500 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Log to /tmp/incomingcall to allow pickup and log into modemlog
|
|
||||||
TIME="$(date --iso-8601=seconds)"
|
TIME="$(date --iso-8601=seconds)"
|
||||||
mkdir -p "$LOGDIR"
|
mkdir -p "$LOGDIR"
|
||||||
printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$LOGDIR/modemlog.tsv"
|
printf %b "$TIME\tcall_ring\t$INCOMINGNUMBER\n" >> "$LOGDIR/modemlog.tsv"
|
||||||
|
@ -67,8 +83,8 @@ checkforincomingcalls() {
|
||||||
sxmo_notificationwrite.sh \
|
sxmo_notificationwrite.sh \
|
||||||
"$NOTIFDIR/incomingcall" \
|
"$NOTIFDIR/incomingcall" \
|
||||||
"sxmo_modemcall.sh pickup $VOICECALLID" \
|
"sxmo_modemcall.sh pickup $VOICECALLID" \
|
||||||
"none" \
|
none \
|
||||||
"Pickup $(sxmo_contacts.sh | grep -E "^$INCOMINGNUMBER")" &
|
"Pickup - $(sxmo_contacts.sh | grep -E "^$INCOMINGNUMBER")" &
|
||||||
|
|
||||||
echo "Number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)"
|
echo "Number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)"
|
||||||
}
|
}
|
||||||
|
@ -101,7 +117,7 @@ checkfornewtexts() {
|
||||||
random \
|
random \
|
||||||
"st -e tail -n9999 -f $LOGDIR/$NUM/sms.txt" \
|
"st -e tail -n9999 -f $LOGDIR/$NUM/sms.txt" \
|
||||||
"$LOGDIR/$NUM/sms.txt" \
|
"$LOGDIR/$NUM/sms.txt" \
|
||||||
"Message from $(sxmo_contacts.sh | grep -E "^$NUM:"): $TEXT" &
|
"Message - $(sxmo_contacts.sh | grep -E "^$NUM:"): $TEXT"
|
||||||
|
|
||||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/sms" ]; then
|
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/sms" ]; then
|
||||||
"$XDG_CONFIG_HOME/sxmo/hooks/sms" "$(sxmo_contacts.sh | grep -E "^$INCOMINGNUMBER")" "$TEXT"
|
"$XDG_CONFIG_HOME/sxmo/hooks/sms" "$(sxmo_contacts.sh | grep -E "^$INCOMINGNUMBER")" "$TEXT"
|
||||||
|
@ -111,6 +127,7 @@ checkfornewtexts() {
|
||||||
|
|
||||||
mainloop() {
|
mainloop() {
|
||||||
while true; do
|
while true; do
|
||||||
|
checkformissedcalls
|
||||||
checkforincomingcalls
|
checkforincomingcalls
|
||||||
checkfornewtexts
|
checkfornewtexts
|
||||||
sleep $TIMEOUT & wait
|
sleep $TIMEOUT & wait
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue