Harden DWM plugins against X11 stacking/keyboard grab races and speed up QMI status

This commit is contained in:
Luxferre
2026-10-25 14:14:21 +02:00
parent b2216c186f
commit e77be498bf
44 changed files with 432 additions and 211 deletions
@@ -65,10 +65,7 @@ detect_qmicli_modem() {
if ! command -v qmicli >/dev/null 2>&1; then
return 1
fi
if timeout 3 qmicli --silent -pd qrtr://0 --uim-noop >/dev/null 2>&1; then
QMICLI_MODEM="timeout 4 qmicli --silent -pd qrtr://0"
return 0
elif [ -e "/dev/wwan0qmi0" ]; then
if [ -e "/dev/wwan0qmi0" ]; then
if timeout 3 qmicli --silent -pd /dev/wwan0qmi0 --device-open-qmi --uim-noop >/dev/null 2>&1; then
QMICLI_MODEM="timeout 4 qmicli --silent -pd /dev/wwan0qmi0 --device-open-qmi"
return 0
@@ -76,6 +73,10 @@ detect_qmicli_modem() {
QMICLI_MODEM="timeout 4 qmicli --silent -d /dev/wwan0qmi0 --device-open-qmi"
return 0
fi
fi
if timeout 3 qmicli --silent -pd qrtr://0 --uim-noop >/dev/null 2>&1; then
QMICLI_MODEM="timeout 4 qmicli --silent -pd qrtr://0"
return 0
elif [ -e "/dev/modem" ]; then
if timeout 3 qmicli --silent -pd /dev/modem --uim-noop >/dev/null 2>&1; then
QMICLI_MODEM="timeout 4 qmicli --silent -pd /dev/modem"
@@ -636,26 +637,23 @@ case "$cmd" in
;;
status)
if ! detect_qmicli_modem; then
echo "MODEM_AVAILABLE=0"
echo "PREFERRED_SLOT=$PREFERRED_SIM_SLOT"
exit 0
QMI_CARDS=""
if command -v qmicli >/dev/null 2>&1; then
if [ -e "/dev/wwan0qmi0" ]; then
QMI_CARDS="$(timeout 3 qmicli --silent -pd /dev/wwan0qmi0 --device-open-qmi --uim-get-card-status 2>/dev/null || true)"
if [ -n "$QMI_CARDS" ]; then
QMICLI_MODEM="timeout 3 qmicli --silent -pd /dev/wwan0qmi0 --device-open-qmi"
fi
fi
if [ -z "$QMI_CARDS" ] && detect_qmicli_modem; then
QMI_CARDS="$($QMICLI_MODEM --uim-get-card-status 2>/dev/null || true)"
fi
fi
QMI_CARDS="$($QMICLI_MODEM --uim-get-card-status 2>/dev/null || true)"
if [ -z "$QMI_CARDS" ]; then
echo "MODEM_AVAILABLE=0"
echo "PREFERRED_SLOT=$PREFERRED_SIM_SLOT"
exit 0
fi
eval "$(parse_uim_card_status "$QMI_CARDS" "$PREFERRED_SIM_SLOT")"
if [ "$PRIMARY_GW_SLOT" = "0" ] && { [ "$SLOT1_STATE" = "present" ] || [ "$SLOT2_STATE" = "present" ]; }; then
SIM_WAIT_TIME=1
provision_slot "$PREFERRED_SIM_SLOT" 2 >/dev/null 2>&1 || true
QMI_CARDS_NEW="$($QMICLI_MODEM --uim-get-card-status 2>/dev/null || true)"
if [ -n "$QMI_CARDS_NEW" ]; then
QMI_CARDS="$QMI_CARDS_NEW"
fi
fi
echo "MODEM_AVAILABLE=1"
parse_uim_card_status "$QMI_CARDS" "$PREFERRED_SIM_SLOT"
QMI_NAS="$($QMICLI_MODEM --nas-get-serving-system 2>/dev/null || true)"