Cleanup hooks
This add a script to use either the user hook or the default one. Sometime we checked the user hook or a default code. We move this default code in a defaut hook. Signed-off-by: Stacy Harper <contact@stacyharper.net> Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
0ed27f8538
commit
e6ea657634
22 changed files with 160 additions and 254 deletions
|
@ -110,10 +110,8 @@ acceptcall() {
|
|||
log_event "call_start" "$CALLID"
|
||||
echo "sxmo_modemcall: Started call $CALLID">&2
|
||||
elif [ "$DIRECTION" = "incoming" ]; then
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/pickup" ]; then
|
||||
echo "sxmo_modemcall: Invoking pickup hook (async)">&2
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/pickup" &
|
||||
fi
|
||||
echo "sxmo_modemcall: Invoking pickup hook (async)">&2
|
||||
sxmo_hooks.sh pickup &
|
||||
touch "$CACHEDIR/${CALLID}.pickedupcall" #this signals that we picked this call up
|
||||
#to other asynchronously running processes
|
||||
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --accept
|
||||
|
@ -134,10 +132,8 @@ hangup() {
|
|||
else
|
||||
#this call was never picked up and hung up immediately, so it is a discarded call
|
||||
touch "$CACHEDIR/${CALLID}.discardedcall" #this signals that we discarded this call to other asynchronously running processes
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/discard" ]; then
|
||||
echo "sxmo_modemcall: Invoking discard hook (async)">&2
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/discard" &
|
||||
fi
|
||||
echo "sxmo_modemcall: Invoking discard hook (async)">&2
|
||||
sxmo_hooks.sh discard &
|
||||
log_event "call_discard" "$CALLID"
|
||||
fi
|
||||
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --hangup
|
||||
|
@ -228,10 +224,8 @@ pickup() {
|
|||
|
||||
mute() {
|
||||
touch "$CACHEDIR/$1.mutedring" #this signals that we muted this ring
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" ]; then
|
||||
echo "sxmo_modemmonitor: Invoking mute_ring hook (async)">&2
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" "$CONTACTNAME" &
|
||||
fi
|
||||
echo "sxmo_modemmonitor: Invoking mute_ring hook (async)">&2
|
||||
sxmo_hooks.sh mute_ring "$CONTACTNAME" &
|
||||
log_event "ring_mute" "$1"
|
||||
finish "Ringing with $NUMBER muted"
|
||||
}
|
||||
|
|
|
@ -125,10 +125,8 @@ checkforfinishedcalls() {
|
|||
echo "sxmo_modemmonitor: Missed call from $FINISHEDNUMBER">&2
|
||||
printf %b "$TIME\tcall_missed\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
|
||||
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/missed_call" ]; then
|
||||
echo "sxmo_modemmonitor: Invoking missed call hook (async)">&2
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/missed_call" "$CONTACTNAME" &
|
||||
fi
|
||||
echo "sxmo_modemmonitor: Invoking missed call hook (async)">&2
|
||||
sxmo_hooks.sh missed_call "$CONTACTNAME" &
|
||||
|
||||
CONTACT="$(lookupcontactname "$FINISHEDNUMBER")"
|
||||
sxmo_notificationwrite.sh \
|
||||
|
@ -168,12 +166,8 @@ checkforincomingcalls() {
|
|||
|
||||
xset dpms force on
|
||||
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
|
||||
echo "sxmo_modemmonitor: Invoking ring hook (async)">&2
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/ring" "$CONTACTNAME" &
|
||||
else
|
||||
sxmo_vibratepine 2500 &
|
||||
fi
|
||||
echo "sxmo_modemmonitor: Invoking ring hook (async)">&2
|
||||
sxmo_hooks.sh ring "$CONTACTNAME" &
|
||||
|
||||
TIME="$(date --iso-8601=seconds)"
|
||||
mkdir -p "$LOGDIR"
|
||||
|
@ -224,9 +218,7 @@ checkfornewtexts() {
|
|||
"$LOGDIR/$NUM/sms.txt" \
|
||||
"Message - $CONTACTNAME: $TEXT"
|
||||
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/sms" ]; then
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/sms" "$CONTACTNAME" "$TEXT"
|
||||
fi
|
||||
sxmo_hooks.sh sms "$CONTACTNAME" "$TEXT"
|
||||
done
|
||||
|
||||
if grep -q modem "$UNSUSPENDREASONFILE" && grep -q crust "$LASTSTATE"; then
|
||||
|
@ -246,7 +238,7 @@ initialmodemstatus() {
|
|||
echo registered > "$MODEMSTATEFILE"
|
||||
elif echo "$state" | grep -q -E "^.*state:.*locked.*$"; then
|
||||
echo locked > "$MODEMSTATEFILE"
|
||||
pidof sxmo_unlocksim.sh || sxmo_unlocksim.sh &
|
||||
pidof unlocksim || sxmo_hooks.sh unlocksim &
|
||||
else
|
||||
echo unknown > "$MODEMSTATEFILE"
|
||||
fi
|
||||
|
@ -290,7 +282,7 @@ mainloop() {
|
|||
read -r newstate
|
||||
if echo "$newstate" | grep "int32 2"; then
|
||||
echo locked > "$MODEMSTATEFILE"
|
||||
pidof sxmo_unlocksim.sh || sxmo_unlocksim.sh &
|
||||
pidof unlocksim || sxmo_hooks.sh unlocksim &
|
||||
elif echo "$newstate" | grep "int32 8"; then
|
||||
echo registered > "$MODEMSTATEFILE"
|
||||
checkforfinishedcalls
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. "$(dirname "$0")/sxmo_common.sh"
|
||||
|
||||
modem_n() {
|
||||
MODEMS="$(mmcli -L)"
|
||||
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
|
||||
return
|
||||
}
|
||||
|
||||
sim_n() {
|
||||
SIMS="$(mmcli -m "$(modem_n)" | grep SIM)"
|
||||
echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2
|
||||
return
|
||||
}
|
||||
|
||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/unlocksim" ]; then
|
||||
"$XDG_CONFIG_HOME/sxmo/hooks/unlocksim" "$(sim_n)"
|
||||
else
|
||||
retry=1
|
||||
pkill dmenu #kill existing dmenu
|
||||
while [ $retry -eq 1 ]; do
|
||||
PICKED="$(
|
||||
# shellcheck disable=SC2039,SC3037
|
||||
echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r "
|
||||
)"
|
||||
if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then
|
||||
retry=0
|
||||
mmcli -i "$(sim_n)" --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1
|
||||
MSG=$(cat /tmp/unlockmsg)
|
||||
[ -n "$MSG" ] && notify-send "$MSG"
|
||||
if echo "$MSG" | grep -q "not SIM-PIN locked"; then
|
||||
retry=0
|
||||
fi
|
||||
else
|
||||
retry=0
|
||||
fi
|
||||
done
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue