|
|
@ -1,14 +1,39 @@ |
|
|
|
#!/usr/bin/env sh |
|
|
|
#!/usr/bin/env sh |
|
|
|
|
|
|
|
LOGDIR=/home/$USER/.sxmo |
|
|
|
|
|
|
|
|
|
|
|
err() { |
|
|
|
err() { |
|
|
|
echo $1 | dmenu -fn Terminus-20 -c -l 10 |
|
|
|
echo -e "$1" | dmenu -fn Terminus-20 -c -l 10 |
|
|
|
exit 1 |
|
|
|
kill $$ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
modem_n() { |
|
|
|
modem_n() { |
|
|
|
mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 |
|
|
|
mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contacts() { |
|
|
|
|
|
|
|
cat $LOGDIR/modemlog.tsv | cut -f3 | sort | uniq | awk NF |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modem_cmd_errcheck() { |
|
|
|
|
|
|
|
ARGS="$@" |
|
|
|
|
|
|
|
RES="$(sudo mmcli $ARGS 2>&1)" |
|
|
|
|
|
|
|
[[ $? -eq 0 ]] || err "Problem executing mmcli command!\n$RES" |
|
|
|
|
|
|
|
echo $RES |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vid_to_number() { |
|
|
|
|
|
|
|
sudo mmcli -m $(modem_n) -o $1 -K | grep call.properties.number | cut -d ':' -f2 | tr -d ' ' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_event() { |
|
|
|
|
|
|
|
EVT_HANDLE="$1" |
|
|
|
|
|
|
|
EVT_VID="$2" |
|
|
|
|
|
|
|
NUMBER="$(vid_to_number $EVT_VID)" |
|
|
|
|
|
|
|
TIME="$(date --iso-8601=seconds)" |
|
|
|
|
|
|
|
echo -ne "$TIME\t$EVT_HANDLE\t$NUMBER\n" >> $LOGDIR/modemlog.tsv |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
toggleflag() { |
|
|
|
toggleflag() { |
|
|
|
TOGGLEFLAG=$1 |
|
|
|
TOGGLEFLAG=$1 |
|
|
|
shift |
|
|
|
shift |
|
|
@ -25,13 +50,15 @@ toggleflag() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dialmenu() { |
|
|
|
dialmenu() { |
|
|
|
NUMS=$(ls -1 ~/.sxmo || "") |
|
|
|
CONTACTS="$(contacts)" |
|
|
|
NUMBER="$( |
|
|
|
NUMBER="$( |
|
|
|
echo -e "$NUMS\nTest Number 804-222-1111" | |
|
|
|
echo -e "Close Menu\n$CONTACTS\nTest Number 804-222-1111" | |
|
|
|
dmenu -l 10 -p Number -c -fn Terminus-20 | |
|
|
|
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -fn Terminus-20 | |
|
|
|
awk -F' ' '{print $NF}' | |
|
|
|
awk -F' ' '{print $NF}' | |
|
|
|
tr -d - |
|
|
|
tr -d - |
|
|
|
)" |
|
|
|
)" |
|
|
|
|
|
|
|
echo $NUMBER | grep "Close Menu" && kill $$ |
|
|
|
|
|
|
|
|
|
|
|
echo "Attempting to dial: $NUMBER" >&2 |
|
|
|
echo "Attempting to dial: $NUMBER" >&2 |
|
|
|
VID="$( |
|
|
|
VID="$( |
|
|
|
sudo mmcli -m $(modem_n) --voice-create-call "number=$NUMBER" | grep -Eo Call/[0-9]+ | grep -oE [0-9]+ |
|
|
|
sudo mmcli -m $(modem_n) --voice-create-call "number=$NUMBER" | grep -Eo Call/[0-9]+ | grep -oE [0-9]+ |
|
|
@ -43,32 +70,40 @@ dialmenu() { |
|
|
|
|
|
|
|
|
|
|
|
startcall() { |
|
|
|
startcall() { |
|
|
|
VID="$1" |
|
|
|
VID="$1" |
|
|
|
sudo mmcli --voice-status -o $VID |
|
|
|
#modem_cmd_errcheck --voice-status -o $VID |
|
|
|
sudo mmcli -m $(modem_n) -o $VID --start | grep "successfully started" || err "Couldn't start call!" |
|
|
|
modem_cmd_errcheck -m $(modem_n) -o $VID --start |
|
|
|
|
|
|
|
log_event "call_start" $VID |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
acceptcall() { |
|
|
|
acceptcall() { |
|
|
|
VID="$1" |
|
|
|
VID="$1" |
|
|
|
echo "Attempting to pickup VID $VID" |
|
|
|
echo "Attempting to pickup VID $VID" |
|
|
|
sudo mmcli --voice-status -o $VID |
|
|
|
#sudo mmcli --voice-status -o $VID |
|
|
|
sudo mmcli -m $(modem_n) -o $VID --accept | grep "successfully" || err "Couldn't accept call!" |
|
|
|
modem_cmd_errcheck -m $(modem_n) -o $VID --accept |
|
|
|
|
|
|
|
log_event "call_pickup" $VID |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hangup() { |
|
|
|
hangup() { |
|
|
|
VID=$1 |
|
|
|
VID=$1 |
|
|
|
sudo mmcli -m $(modem_n) -o $VID --hangup | grep "successfully hung up" || err "Failed to hangup the call?" |
|
|
|
modem_cmd_errcheck -m $(modem_n) -o $VID --hangup |
|
|
|
|
|
|
|
log_event "call_hangup" $VID |
|
|
|
|
|
|
|
err "Call hungup ok" |
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
incallmenu() { |
|
|
|
incallmenu() { |
|
|
|
DMENUIDX=0 |
|
|
|
DMENUIDX=0 |
|
|
|
VID="$1" |
|
|
|
VID="$1" |
|
|
|
NUMBER=$(mmcli -m $(modem_n) -o $VID -K | grep call.properties.number | cut -d ':' -f2 | tr -d ' ') |
|
|
|
NUMBER="$(vid_to_number $VID)" |
|
|
|
# E.g. Run once w/o -2, and then run once with -2 |
|
|
|
|
|
|
|
FLAGS="-e -m" |
|
|
|
# E.g. There's some bug with the modem that' requires us to toggle the |
|
|
|
sxmo_megiaudioroute $FLAGS |
|
|
|
# DAI a few times before starting the call for it to kick in |
|
|
|
FLAGS="$FLAGS -2" |
|
|
|
FLAGS=" " |
|
|
|
sxmo_megiaudioroute $FLAGS |
|
|
|
FLAGS="$(toggleflag "-e" "$FLAGS")" |
|
|
|
|
|
|
|
FLAGS="$(toggleflag "-m" "$FLAGS")" |
|
|
|
|
|
|
|
FLAGS="$(toggleflag "-2" "$FLAGS")" |
|
|
|
|
|
|
|
FLAGS="$(toggleflag "-2" "$FLAGS")" |
|
|
|
|
|
|
|
FLAGS="$(toggleflag "-2" "$FLAGS")" |
|
|
|
|
|
|
|
|
|
|
|
while true |
|
|
|
while true |
|
|
|
do |
|
|
|
do |
|
|
@ -79,19 +114,20 @@ incallmenu() { |
|
|
|
echo -- "$FLAGS" | grep -- "-s" && TSPEAKER="Speakerphone Off" || TSPEAKER="Speakerphone On" |
|
|
|
echo -- "$FLAGS" | grep -- "-s" && TSPEAKER="Speakerphone Off" || TSPEAKER="Speakerphone On" |
|
|
|
|
|
|
|
|
|
|
|
CHOICES="$(echo -ne ' |
|
|
|
CHOICES="$(echo -ne ' |
|
|
|
Volume ↑ ^ sxmo_vol.sh up |
|
|
|
Volume ↑ ^ sxmo_vol.sh up |
|
|
|
Volume ↓ ^ sxmo_vol.sh down |
|
|
|
Volume ↓ ^ sxmo_vol.sh down |
|
|
|
TMUTE ^ FLAGS="$(toggleflag "-m" "$FLAGS")" |
|
|
|
TMUTE ^ FLAGS="$(toggleflag "-m" "$FLAGS")" |
|
|
|
TECHO ^ FLAGS="$(toggleflag "-z" "$FLAGS")" |
|
|
|
TECHO ^ FLAGS="$(toggleflag "-z" "$FLAGS")" |
|
|
|
TEARPIECE ^ FLAGS="$(toggleflag "-e" "$FLAGS")" |
|
|
|
TEARPIECE ^ FLAGS="$(toggleflag "-e" "$FLAGS")" |
|
|
|
TLINEJACK ^ FLAGS="$(toggleflag "-h" "$FLAGS")" |
|
|
|
TLINEJACK ^ FLAGS="$(toggleflag "-h" "$FLAGS")" |
|
|
|
TSPEAKER ^ FLAGS="$(toggleflag "-s" "$FLAGS")" |
|
|
|
TSPEAKER ^ FLAGS="$(toggleflag "-s" "$FLAGS")" |
|
|
|
DTMF Tones ^ dtmfmenu $VID |
|
|
|
DTMF Tones ^ dtmfmenu $VID |
|
|
|
Hangup ^ hangup $VID |
|
|
|
Hangup ^ hangup $VID |
|
|
|
Lock Screen ^ sxmo_screenlock |
|
|
|
Lock Screen ^ sxmo_screenlock |
|
|
|
' | sed "s/TMUTE/$TMUTE/;s/TECHO/$TECHO/;s/TEARPIECE/$TEARPIECE/;s/TLINEJACK/$TLINEJACK/;s/TSPEAKER/$TSPEAKER/" |
|
|
|
' | sed "s/TMUTE/$TMUTE/;s/TECHO/$TECHO/;s/TEARPIECE/$TEARPIECE/;s/TLINEJACK/$TLINEJACK/;s/TSPEAKER/$TSPEAKER/" |
|
|
|
)" |
|
|
|
)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PICKED="" |
|
|
|
PICKED=$( |
|
|
|
PICKED=$( |
|
|
|
echo "$CHOICES" | |
|
|
|
echo "$CHOICES" | |
|
|
|
xargs -0 echo | |
|
|
|
xargs -0 echo | |
|
|
@ -100,6 +136,10 @@ incallmenu() { |
|
|
|
awk '{$1=$1};1' | |
|
|
|
awk '{$1=$1};1' | |
|
|
|
dmenu -idx $DMENUIDX -l 14 -c -fn "Terminus-30" -p "$NUMBER" |
|
|
|
dmenu -idx $DMENUIDX -l 14 -c -fn "Terminus-30" -p "$NUMBER" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# E.g. in modem watcher script we just kill dmenu if the other side hangsup |
|
|
|
|
|
|
|
echo "$PICKED" | grep -Ev "." && err "$NUMBER hung up the call" |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
eval $CMD |
|
|
|
eval $CMD |
|
|
@ -108,19 +148,18 @@ incallmenu() { |
|
|
|
|
|
|
|
|
|
|
|
dtmfmenu() { |
|
|
|
dtmfmenu() { |
|
|
|
VID=$1 |
|
|
|
VID=$1 |
|
|
|
DMENUIDX=0 |
|
|
|
DTMFINDEX=0 |
|
|
|
NUMS="0123456789*#ABCD" |
|
|
|
NUMS="0123456789*#ABCD" |
|
|
|
|
|
|
|
|
|
|
|
while true |
|
|
|
while true |
|
|
|
do |
|
|
|
do |
|
|
|
PICKED="$( |
|
|
|
PICKED="$( |
|
|
|
echo "$NUMS" | grep -o . | sed '1 iReturn to Call Menu' | |
|
|
|
echo "$NUMS" | grep -o . | sed '1 iReturn to Call Menu' | |
|
|
|
dmenu -l 20 -fn Terminus-20 -c -idx $DMENUIDX -p "DTMF Tone" |
|
|
|
dmenu -l 20 -fn Terminus-20 -c -idx $DTMFINDEX -p "DTMF Tone" |
|
|
|
)" |
|
|
|
)" |
|
|
|
DMENUIDX=$(echo "$NUMS" | grep -bo "$PICKED" | cut -d: -f1 | xargs -IN echo 2+N | bc) |
|
|
|
echo "$PICKED" | grep "Return to Call Menu" && return |
|
|
|
|
|
|
|
DTMFINDEX=$(echo "$NUMS" | grep -bo "$PICKED" | cut -d: -f1 | xargs -IN echo 2+N | bc) |
|
|
|
echo "$PICKED" | grep "Return to Call Menu" && break |
|
|
|
modem_cmd_errcheck -m $(modem_n) -o $VID --send-dtmf="$PICKED" |
|
|
|
sudo mmcli -m $(modem_n) -o $VID --send-dtmf="$PICKED" |
|
|
|
|
|
|
|
done |
|
|
|
done |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|