Implements --dry-run for check call

It obviously can't answer a call that isn't coming in, but it creates
the rofi prompt
master
Jonathan Hodgson 4 years ago
parent 195258e79c
commit 49c7a32c7f
  1. 55
      bin/.bin/modem/checkCall

@ -46,8 +46,7 @@ prompt-incoming(){
local reject="" local reject=""
local choice='' local choice=''
# Used for testing local contact="$1"
local contact="${1:-01234 567890}"
local prompt="$(echo -en "Incoming Call\n$contact")" local prompt="$(echo -en "Incoming Call\n$contact")"
@ -63,31 +62,13 @@ prompt-incoming(){
esac esac
} }
mkdir -p "$CALL_DIR"
dryrun="false"
# Assume we want the first modem
# can be overwritten by the -m option
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) usage; exit;;
-m|--modem) modem="$2"; shift ;;
--dry-run) dryrun="true" ;;
--) shift; break ;;
*) die "invalid option: '$1'." ;;
esac
shift
done
checkIncoming(){ checkIncoming(){
export DISPLAY=:0.0 export DISPLAY=:0.0
if [ "$dryrun" = "true" ]; then
prompt-incoming "+441234567890"
return
fi
local id="$( mmcli -m "$modem" --voice-list-calls | local id="$( mmcli -m "$modem" --voice-list-calls |
grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )" grep -Eo '[0-9]+ incoming \(ringing-in\)' | grep -Eo '[0-9]+' )"
@ -117,7 +98,6 @@ checkFinished(){
[ "$count" -eq 0 ] && return [ "$count" -eq 0 ] && return
echo "$ids" | while read -r id; do echo "$ids" | while read -r id; do
# Delete from the modem # Delete from the modem
local number="$(lookupnumberfromcallid "$id")" local number="$(lookupnumberfromcallid "$id")"
@ -138,5 +118,30 @@ checkFinished(){
done done
} }
mkdir -p "$CALL_DIR"
dryrun="false"
# Assume we want the first modem
# can be overwritten by the -m option
modem="$(mmcli -L | grep -oE 'Modem\/[0-9]+' | head -n 1 | cut -d'/' -f2)"
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) usage; exit;;
-m|--modem) modem="$2"; shift ;;
--dry-run) dryrun="true" ;;
--) shift; break ;;
*) die "invalid option: '$1'." ;;
esac
shift
done
checkIncoming & checkIncoming &
checkFinished & checkFinished &

Loading…
Cancel
Save