Pull dialing functionality into seperate script; allows in-call check to be valid
This commit is contained in:
parent
391df5db6a
commit
c119ab0145
3 changed files with 66 additions and 44 deletions
|
@ -188,7 +188,7 @@ programchoicesinit() {
|
||||||
Apps ^ 0 ^ sxmo_appmenu.sh applications
|
Apps ^ 0 ^ sxmo_appmenu.sh applications
|
||||||
Files ^ 0 ^ sxmo_files.sh
|
Files ^ 0 ^ sxmo_files.sh
|
||||||
Maps ^ 0 ^ foxtrotgps
|
Maps ^ 0 ^ foxtrotgps
|
||||||
Dialer ^ 0 ^ sxmo_modemcall.sh dial
|
Dialer ^ 0 ^ sxmo_modemdial.sh
|
||||||
Texts ^ 0 ^ sxmo_modemtext.sh
|
Texts ^ 0 ^ sxmo_modemtext.sh
|
||||||
Camera ^ 0 ^ sxmo_camera.sh
|
Camera ^ 0 ^ sxmo_camera.sh
|
||||||
Wifi ^ 0 ^ st -e nmtui
|
Wifi ^ 0 ^ st -e nmtui
|
||||||
|
|
|
@ -37,7 +37,12 @@ modem_cmd_errcheck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
vid_to_number() {
|
vid_to_number() {
|
||||||
mmcli -m "$(modem_n)" -o "$1" -K | grep call.properties.number | cut -d ':' -f2 | tr -d ' ' | sed 's/^[+]//' | sed 's/^1//'
|
mmcli -m "$(modem_n)" -o "$1" -K |
|
||||||
|
grep call.properties.number |
|
||||||
|
cut -d ':' -f2 |
|
||||||
|
tr -d ' ' |
|
||||||
|
sed 's/^[+]//' |
|
||||||
|
sed 's/^1//'
|
||||||
}
|
}
|
||||||
|
|
||||||
log_event() {
|
log_event() {
|
||||||
|
@ -69,42 +74,24 @@ toggleflagset() {
|
||||||
FLAGS="$(toggleflag "$1" "$FLAGS")"
|
FLAGS="$(toggleflag "$1" "$FLAGS")"
|
||||||
}
|
}
|
||||||
|
|
||||||
dialmenu() {
|
|
||||||
CONTACTS="$(contacts)"
|
|
||||||
NUMBER="$(
|
|
||||||
printf %b "Close Menu\n$CONTACTS" |
|
|
||||||
grep . |
|
|
||||||
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20
|
|
||||||
)"
|
|
||||||
echo "$NUMBER" | grep "Close Menu" && kill 0
|
|
||||||
|
|
||||||
NUMBER="$(echo "$NUMBER" | awk -F' ' '{print $NF}' | tr -d -)"
|
|
||||||
echo "$NUMBER" | grep -qE '^[+0-9]+$' || fatalerr "$NUMBER is not a number"
|
|
||||||
|
|
||||||
echo "Attempting to dial: $NUMBER" >&2
|
|
||||||
CALLID="$(
|
|
||||||
mmcli -m "$(modem_n)" --voice-create-call "number=$NUMBER" |
|
|
||||||
grep -Eo "Call/[0-9]+" |
|
|
||||||
grep -oE "[0-9]+"
|
|
||||||
)"
|
|
||||||
echo "Starting call with CALLID: $CALLID" >&2
|
|
||||||
startcall "$CALLID" >&2
|
|
||||||
echo "$CALLID"
|
|
||||||
}
|
|
||||||
|
|
||||||
startcall() {
|
|
||||||
CALLID="$1"
|
|
||||||
#modem_cmd_errcheck --voice-status -o $CALLID
|
|
||||||
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --start
|
|
||||||
log_event "call_start" "$CALLID"
|
|
||||||
}
|
|
||||||
|
|
||||||
acceptcall() {
|
acceptcall() {
|
||||||
CALLID="$1"
|
CALLID="$1"
|
||||||
echo "Attempting to pickup CALLID $CALLID"
|
echo "Attempting to initialize CALLID $CALLID"
|
||||||
#mmcli --voice-status -o $CALLID
|
DIRECTION="$(
|
||||||
|
mmcli --voice-status -o "$CALLID" -K |
|
||||||
|
grep call.properties.direction |
|
||||||
|
cut -d: -f2 |
|
||||||
|
tr -d " "
|
||||||
|
)"
|
||||||
|
if [ "$DIRECTION" = "outgoing" ]; then
|
||||||
|
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --start
|
||||||
|
log_event "call_start" "$CALLID"
|
||||||
|
elif [ "$DIRECTION" = "incoming" ]; then
|
||||||
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"
|
||||||
|
else
|
||||||
|
fatalerr "Couldn't initialize call with callid <$CALLID>; unknown direction <$DIRECTION>"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
hangup() {
|
hangup() {
|
||||||
|
@ -200,14 +187,6 @@ dtmfmenu() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dial() {
|
|
||||||
CALLID="$(dialmenu)"
|
|
||||||
incallsetup "$CALLID"
|
|
||||||
incallmonitor "$CALLID" &
|
|
||||||
incallmenuloop "$CALLID"
|
|
||||||
}
|
|
||||||
|
|
||||||
pickup() {
|
pickup() {
|
||||||
acceptcall "$1"
|
acceptcall "$1"
|
||||||
incallsetup "$1"
|
incallsetup "$1"
|
||||||
|
|
43
scripts/modem/sxmo_modemdial.sh
Executable file
43
scripts/modem/sxmo_modemdial.sh
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
LOGDIR="$XDG_CONFIG_HOME"/sxmo/modem
|
||||||
|
trap "gracefulexit" INT TERM
|
||||||
|
|
||||||
|
fatalerr() {
|
||||||
|
# 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
|
||||||
|
notify-send "$1"
|
||||||
|
(sleep 0.5; echo 1 > /tmp/sxmo_bar) &
|
||||||
|
kill -9 0
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_n() {
|
||||||
|
MODEMS="$(mmcli -L)"
|
||||||
|
echo "$MODEMS" | grep -qoE 'Modem\/([0-9]+)' || fatalerr "Couldn't find modem - is your modem enabled?"
|
||||||
|
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
|
||||||
|
}
|
||||||
|
|
||||||
|
dialmenu() {
|
||||||
|
CONTACTS="$(contacts)"
|
||||||
|
NUMBER="$(
|
||||||
|
printf %b "Close Menu\n$CONTACTS" |
|
||||||
|
grep . |
|
||||||
|
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20
|
||||||
|
)"
|
||||||
|
echo "$NUMBER" | grep "Close Menu" && kill 0
|
||||||
|
|
||||||
|
NUMBER="$(echo "$NUMBER" | awk -F' ' '{print $NF}' | tr -d -)"
|
||||||
|
echo "$NUMBER" | grep -qE '^[+0-9]+$' || fatalerr "$NUMBER is not a number"
|
||||||
|
|
||||||
|
echo "Attempting to dial: $NUMBER" >&2
|
||||||
|
CALLID="$(
|
||||||
|
mmcli -m "$(modem_n)" --voice-create-call "number=$NUMBER" |
|
||||||
|
grep -Eo "Call/[0-9]+" |
|
||||||
|
grep -oE "[0-9]+"
|
||||||
|
)"
|
||||||
|
echo "Starting call with CALLID: $CALLID" >&2
|
||||||
|
echo "$CALLID"
|
||||||
|
}
|
||||||
|
|
||||||
|
modem_n || fatalerr "Couldn't determine modem number - is modem online?"
|
||||||
|
CREATEDCALLID="$(dialmenu)"
|
||||||
|
sxmo_modemcall.sh pickup "$CREATEDCALLID"
|
Loading…
Add table
Add a link
Reference in a new issue