From fa3550c638b27e274e646b3a07885d5288da55ad Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Wed, 20 May 2020 16:52:00 -0500 Subject: [PATCH] Add warnings to modem scripts if the modem is not present --- scripts/core/sxmo_statusbar.sh | 2 +- scripts/core/sxmo_xinit.sh | 1 - scripts/modem/sxmo_modemcall.sh | 4 +++- scripts/modem/sxmo_modeminfo.sh | 10 +++++++++- scripts/modem/sxmo_modemmonitor.sh | 10 +++++++++- scripts/modem/sxmo_modemtext.sh | 4 +++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/scripts/core/sxmo_statusbar.sh b/scripts/core/sxmo_statusbar.sh index b398c4c..d4852d8 100755 --- a/scripts/core/sxmo_statusbar.sh +++ b/scripts/core/sxmo_statusbar.sh @@ -12,7 +12,7 @@ touch $UPDATEFILE while : do - # M symbol if modem monitoring is on + # M symbol if modem monitoring is on & modem present MODEMMON="" pgrep -f sxmo_modemmonitor.sh && MODEMMON="M " diff --git a/scripts/core/sxmo_xinit.sh b/scripts/core/sxmo_xinit.sh index f9d6ace..ae1fa04 100755 --- a/scripts/core/sxmo_xinit.sh +++ b/scripts/core/sxmo_xinit.sh @@ -7,7 +7,6 @@ xmodmap /usr/share/sxmo/xmodmap_caps_esc xsetroot -mod 3 2 -fg '#000000' -bg '#888888' xset s off -dpms alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore -sxmo_modemmonitor.sh & #xset r off # E.g. for PBP diff --git a/scripts/modem/sxmo_modemcall.sh b/scripts/modem/sxmo_modemcall.sh index 7da3f94..159a33a 100755 --- a/scripts/modem/sxmo_modemcall.sh +++ b/scripts/modem/sxmo_modemcall.sh @@ -10,7 +10,9 @@ err() { } modem_n() { - mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 + MODEMS="$(mmcli -L)" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' > /dev/null || err "Couldn't find modem - is you're modem enabled?" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 } contacts() { diff --git a/scripts/modem/sxmo_modeminfo.sh b/scripts/modem/sxmo_modeminfo.sh index 9078fc2..cc1840b 100755 --- a/scripts/modem/sxmo_modeminfo.sh +++ b/scripts/modem/sxmo_modeminfo.sh @@ -1,6 +1,14 @@ #!/usr/bin/env sh + +err() { + echo -e "$1" | dmenu -fn Terminus-20 -c -l 10 + exit +} + modem_n() { - mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 + MODEMS="$(mmcli -L)" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' > /dev/null || err "Couldn't find modem - is you're modem enabled?" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 } st -e sh -c "mmcli -m $(modem_n) && read" diff --git a/scripts/modem/sxmo_modemmonitor.sh b/scripts/modem/sxmo_modemmonitor.sh index e0359e7..69e4b54 100755 --- a/scripts/modem/sxmo_modemmonitor.sh +++ b/scripts/modem/sxmo_modemmonitor.sh @@ -2,9 +2,17 @@ TIMEOUT=3 LOGDIR=/home/$USER/.sxmo ACTIVECALL="NONE" +trap "kill 0" SIGINT + +err() { + echo -e "$1" | dmenu -fn Terminus-20 -c -l 10 + kill -9 0 +} modem_n() { - mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 + MODEMS="$(mmcli -L)" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' > /dev/null || err "Couldn't find modem - is you're modem enabled?\nDisabling modem monitor" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 } newcall() { diff --git a/scripts/modem/sxmo_modemtext.sh b/scripts/modem/sxmo_modemtext.sh index c738b0c..9077d68 100755 --- a/scripts/modem/sxmo_modemtext.sh +++ b/scripts/modem/sxmo_modemtext.sh @@ -8,7 +8,9 @@ err() { } modem_n() { - mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 + MODEMS="$(mmcli -L)" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' > /dev/null || err "Couldn't find modem - is you're modem enabled?" + echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 } textcontacts() {