28 lines
1.0 KiB
Bash
28 lines
1.0 KiB
Bash
#!/bin/sh
|
|||
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||
|
|
# Bananarchy SIM PIN/PUK unlock wrapper — routes to native xmodem plugin UI
|
||
|
|
|
||
|
|
if command -v xmodem >/dev/null 2>&1 && [ -n "${DISPLAY:-}" ]; then
|
||
|
|
exec xmodem unlock
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Fallback if X11 plugin is not running
|
||
|
|
. sxmo_common.sh
|
||
|
|
SIM="$(mmcli -m any 2>/dev/null | grep -oE 'SIM/([0-9]+)' | head -n1 | cut -d'/' -f2 || true)"
|
||
|
|
[ -z "$SIM" ] && exit 0
|
||
|
|
LOCKSTATE="$(mmcli -m any -K 2>/dev/null | grep 'modem.generic.unlock-required' | cut -d':' -f2 | tr -d ' ' || true)"
|
||
|
|
case "$LOCKSTATE" in
|
||
|
|
sim-pin)
|
||
|
|
PIN="$(printf "0000\n1234\nCancel" | sxmo_dmenu.sh -p "PIN")"
|
||
|
|
[ -z "$PIN" ] || [ "$PIN" = "Cancel" ] && exit 0
|
||
|
|
mmcli -i "$SIM" --pin="$PIN"
|
||
|
|
;;
|
||
|
|
sim-puk)
|
||
|
|
PUK="$(printf "Cancel\n" | sxmo_dmenu.sh -p "PUK (8 digits)")"
|
||
|
|
[ -z "$PUK" ] || [ "$PUK" = "Cancel" ] && exit 0
|
||
|
|
NEWPIN="$(printf "0000\n1234\nCancel" | sxmo_dmenu.sh -p "New PIN")"
|
||
|
|
[ -z "$NEWPIN" ] || [ "$NEWPIN" = "Cancel" ] && exit 0
|
||
|
|
mmcli -i "$SIM" --puk="$PUK" --pin="$NEWPIN"
|
||
|
|
;;
|
||
|
|
esac
|