sxmo-utils/configs/default_hooks/unlocksim
Stacy Harper 8a27933c47 SWMO - SXMO over Wayland
This is a huge patch for Swmo, Sxmo over Sway.

It is Dwm backward compatible so dwm users should not expect regressions.

If you install all dependencies, you then can toggle between Sway and Dwm using a new config entry. It will reboot the phone.

This commit also contains:
    * Make the modemmonitor bullet proof
    * various other smaller fixes

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2021-08-22 13:23:22 +02:00

37 lines
848 B
Bash

#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(which sxmo_common.sh)"
modem_n() {
MODEMS="$(mmcli -L)"
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
return
}
sim_n() {
SIMS="$(mmcli -m "$(modem_n)" | grep SIM)"
echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2
return
}
retry=1
sxmo_dmenu.sh close
while [ $retry -eq 1 ]; do
PICKED="$(
# shellcheck disable=SC2039,SC3037
echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r "
)"
if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then
retry=0
mmcli -i "$(sim_n)" --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1
MSG=$(cat /tmp/unlockmsg)
[ -n "$MSG" ] && notify-send "$MSG"
if echo "$MSG" | grep -q "not SIM-PIN locked"; then
retry=0
fi
else
retry=0
fi
done