Fix SIM2 QMI UIM provisioning, auto-enable ModemManager, PIN auto-prompt, call audio, and Dunst clearing
This commit is contained in:
@@ -15,22 +15,68 @@ newstate="$2"
|
||||
|
||||
sxmo_debug "$2 (old: $1 [reason: $3])"
|
||||
|
||||
case "$newstate" in
|
||||
"locked")
|
||||
sxmo_log "State is locked. Opening SIM PIN/PUK unlock dialog."
|
||||
open_sim_unlock_ui() {
|
||||
(
|
||||
i=0
|
||||
while [ "$i" -lt 40 ] && [ ! -p /tmp/dwm_plugin_modem.fifo ]; do
|
||||
sleep 0.2
|
||||
i=$((i + 1))
|
||||
done
|
||||
if command -v xmodem >/dev/null 2>&1; then
|
||||
xmodem unlock >/dev/null 2>&1 &
|
||||
DISPLAY="${DISPLAY:-:0}" xmodem unlock >/dev/null 2>&1 &
|
||||
elif ! pgrep -f "sxmo_unlocksim.sh" >/dev/null; then
|
||||
sxmo_unlocksim.sh &
|
||||
fi
|
||||
) &
|
||||
}
|
||||
|
||||
case "$newstate" in
|
||||
"locked")
|
||||
sxmo_log "State is locked. Opening SIM PIN/PUK unlock dialog."
|
||||
open_sim_unlock_ui
|
||||
;;
|
||||
"failed")
|
||||
sxmo_log "State is failed. Checking QMI UIM status for SIM2/PIN lock."
|
||||
(
|
||||
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
||||
if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then
|
||||
sxmo_log "QMI UIM reports locked SIM while ModemManager state is failed; opening unlock UI."
|
||||
open_sim_unlock_ui
|
||||
elif printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_STATE=present" && printf "%s\n" "$uim_st" | grep -q "^PRIMARY_GW_SLOT=0$"; then
|
||||
now_ts="$(date +%s 2>/dev/null || echo 0)"
|
||||
last_ts="$(cat /tmp/sxmo_modem_reprov.stamp 2>/dev/null || echo 0)"
|
||||
if [ $((now_ts - last_ts)) -ge 25 ]; then
|
||||
echo "$now_ts" > /tmp/sxmo_modem_reprov.stamp
|
||||
sxmo_log "Unprovisioned SIM detected in failed state; running msm-modem-uim-selection boot."
|
||||
doas -n /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
|
||||
sxmo_hook_statusbar.sh modem >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
) &
|
||||
;;
|
||||
"disabled")
|
||||
sxmo_log "State is disabled. Enabling modem and registering on network."
|
||||
(
|
||||
mmcli -m any -e >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
mmcli -m any --3gpp-register-home >/dev/null 2>&1 || true
|
||||
sxmo_hook_statusbar.sh modem >/dev/null 2>&1 || true
|
||||
) &
|
||||
;;
|
||||
"enabling")
|
||||
sxmo_log "State is enabling. Clearing stale call files."
|
||||
rm "$XDG_RUNTIME_DIR"/sxmo_calls/* 2>/dev/null || true
|
||||
rm -f "$SXMO_NOTIFDIR"/incomingcall* 2>/dev/null || true
|
||||
;;
|
||||
"registered")
|
||||
sxmo_log "State is registered. Checking for calls and messages."
|
||||
"enabled")
|
||||
sxmo_log "State is enabled. Requesting 3GPP network registration."
|
||||
(
|
||||
mmcli -m any --3gpp-register-home >/dev/null 2>&1 || true
|
||||
sxmo_hook_statusbar.sh modem >/dev/null 2>&1 || true
|
||||
) &
|
||||
;;
|
||||
"registered"|"connected")
|
||||
sxmo_log "State is $newstate. Checking for calls and messages."
|
||||
|
||||
# kill the pin-entry dmenu if still open
|
||||
pkill -f sxmo_unlocksim.sh 2>/dev/null || true
|
||||
|
||||
@@ -59,6 +59,13 @@ set_modem() {
|
||||
MODEMSTATE="$(printf %s "$MMCLI" | jq -r .modem.generic.state)"
|
||||
fi
|
||||
|
||||
if [ "$MODEMSTATE" = "failed" ] || [ "$MODEMSTATE" = "nomodem" ]; then
|
||||
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
||||
if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then
|
||||
MODEMSTATE="locked"
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$MODEMSTATE" in
|
||||
nomodem)
|
||||
fgcolor=red
|
||||
@@ -119,7 +126,7 @@ set_modem() {
|
||||
sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \
|
||||
modem-state 10 "$MODEMSTATECMP"
|
||||
|
||||
if [ "$MODEMSTATE" = nomodem ]; then
|
||||
if [ "$MODEMSTATE" = nomodem ] || [ "$MODEMSTATE" = locked ] || [ "$MODEMSTATE" = failed ] || [ "$MODEMSTATE" = unknown ]; then
|
||||
sxmobar -d modem-tech
|
||||
sxmobar -d modem-signal
|
||||
return
|
||||
@@ -131,7 +138,7 @@ set_modem() {
|
||||
style=normal
|
||||
|
||||
# see https://www.freedesktop.org/software/ModemManager/api/latest/ModemManager-Flags-and-Enumerations.html#MMModemAccessTechnology
|
||||
USEDTECHS="$(printf %s "$MMCLI" | jq -r '.modem.generic."access-technologies"[]')"
|
||||
USEDTECHS="$(printf %s "$MMCLI" | jq -r '.modem.generic."access-technologies"[]? // empty' 2>/dev/null)"
|
||||
case "$USEDTECHS" in
|
||||
*5gnr*)
|
||||
MODEMTECHCMP="$icon_modem_fiveg"
|
||||
@@ -178,7 +185,10 @@ set_modem() {
|
||||
|
||||
case "$MODEMSTATE" in
|
||||
registered|connected|connecting|disconnecting)
|
||||
MODEMSIGNAL="$(printf %s "$MMCLI" | jq -r '.modem.generic."signal-quality".value')"
|
||||
MODEMSIGNAL="$(printf %s "$MMCLI" | jq -r '.modem.generic."signal-quality".value // 0' 2>/dev/null)"
|
||||
case "$MODEMSIGNAL" in
|
||||
''|*[!0-9]*) MODEMSIGNAL=0 ;;
|
||||
esac
|
||||
if [ "$MODEMSIGNAL" -lt 33 ]; then
|
||||
MODEMSIGNALCMP="$icon_modem_signal_1"
|
||||
elif [ "$MODEMSIGNAL" -lt 66 ]; then
|
||||
|
||||
Reference in New Issue
Block a user