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>
This commit is contained in:
Stacy Harper 2021-08-22 12:49:51 +02:00 committed by Maarten van Gompel
parent b1403f983e
commit 8a27933c47
54 changed files with 1500 additions and 545 deletions

View file

@ -10,31 +10,74 @@
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
if [ "$1" = "reset" ]; then
#does a hard reset of the entire modem
echo "sxmo_modemmonitortoggle: forcing modem reset">&2
notify-send "Resetting modem, this may take a minute..."
pkill -TERM -f sxmo_modemmonitor.sh
ensure_daemon() {
TRIES=0
while ! rc-service "$1" status | grep -q started; do
if [ "$TRIES" -eq 10 ]; then
return 1
fi
TRIES=$((TRIES+1))
sudo rc-service "$1" start
sleep 5
done
return 0
}
ensure_daemons() {
if (rc-service eg25-manager status | grep -q started) &&
(rc-service modemmanager status | grep -q started); then
return
fi
echo "sxmo_modemmonitortoggle: forcing modem restart" >&2
notify-send "Resetting modem daemons, this may take a minute..."
sudo rc-service modemmanager stop
sudo rc-service eg25-manager stop
sleep 5
while ! rc-service eg25-manager status | grep -q started; do
sudo rc-service eg25-manager start
sleep 2
sleep 2
if ! (ensure_daemon eg25-manager && ensure_daemon modemmanager); then
printf "failed\n" > "$MODEMSTATEFILE"
notify-send --urgency=critical "We failed to start the modem daemons. We may need hard reboot."
return 1
fi
}
on() {
rm "$NOTIFDIR"/incomingcall*
TRIES=0
while ! printf %s "$(mmcli -L)" 2> /dev/null | grep -qoE 'Modem\/([0-9]+)'; do
TRIES=$((TRIES+1))
if [ "$TRIES" -eq 10 ]; then
printf "failed\n" > "$MODEMSTATEFILE"
notify-send --urgency=critical "We failed to start the modem monitor. We may need hard reboot."
fi
sleep 5
done
sleep 5
sudo rc-service modemmanager start
sleep 30
setsid -f sxmo_modemmonitor.sh &
elif [ "$1" != "on" ] && pgrep -f sxmo_modemmonitor.sh; then
sleep 1
}
off() {
pkill -TERM -f sxmo_modemmonitor.sh
elif [ "$1" != "off" ] && ! pgrep -f sxmo_modemmonitor.sh; then
setsid -f sxmo_modemmonitor.sh &
}
if [ -z "$1" ]; then
if pgrep -f sxmo_modemmonitor.sh; then
set -- off
else
set -- on
fi
fi
rm "$NOTIFDIR"/incomingcall*
# E.g. wait until process killed or started -- maybe there's a better way..
sleep 1
case "$1" in
restart) off; ensure_daemons && on;;
on) ensure_daemons && on;;
off) off;;
esac
sxmo_statusbarupdate.sh