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

@ -26,7 +26,7 @@ finish() {
notify-send "$1"
fi
[ -n "$LOCKPID" ] && kill "$LOCKPID"
pkill -9 dmenu
sxmo_dmemu.sh close
exit 1
}
@ -181,13 +181,13 @@ incallmenuloop() {
$icon_phx Hangup ^ hangup $CALLID
"
pkill -9 dmenu # E.g. just incase user is playing with btns or hits a menu by mistake
pkill -9 bemenu # E.g. just incase user is playing with btns or hits a menu by mistake
echo "$CHOICES" |
xargs -0 echo |
cut -d'^' -f1 |
sed '/^[[:space:]]*$/d' |
awk '{$1=$1};1' | #this cryptic statement trims leading/trailing whitespace from a string
dmenu -idx $DMENUIDX -l 14 "$([ "$WINDOWIFIED" = 0 ] && echo "-c" || echo "-wm")" -p "$NUMBER" |
dmenu -ix $DMENUIDX "$([ "$WINDOWIFIED" = 0 ] && echo "" || echo "-wm")" -p "$NUMBER" |
(
PICKED="$(cat)";
echo "sxmo_modemcall: Picked is $PICKED">&2
@ -207,7 +207,7 @@ dtmfmenu() {
while true; do
PICKED="$(
echo "$NUMS" | grep -o . | sed '1 iReturn to Call Menu' |
dmenu "$([ "$WINDOWIFIED" = 0 ] && echo "-c" || echo "-wm")" -l 20 -c -p "DTMF Tone"
dmenu "$([ "$WINDOWIFIED" = 0 ] && echo "" || echo "-wm")" -p "DTMF Tone"
)"
echo "$PICKED" | grep "Return to Call Menu" && return
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --send-dtmf="$PICKED"
@ -234,7 +234,7 @@ incomingcallmenu() {
PICKED="$(
printf %b "$icon_phn Pickup\n$icon_phx Hangup\n$icon_mut Mute\n" |
dmenu -c -l 5 -p "$CONTACTNAME"
dmenu -p "$CONTACTNAME"
)" || exit
if echo "$PICKED" | grep -q "Pickup"; then

View file

@ -28,14 +28,14 @@ dialmenu() {
NUMBER="$(
printf %b "Close Menu\nMore contacts\n$CONTACTS" |
grep . |
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -i
sxmo_dmenu_with_kb.sh -p Number -i
)"
echo "$NUMBER" | grep "Close Menu" && kill -9 0
echo "$NUMBER" | grep -q "More contacts" && NUMBER="$(
printf %b "Close Menu\n$(sxmo_contacts.sh --all)" |
grep . |
sxmo_dmenu_with_kb.sh -l 10 -p Number -c -i
sxmo_dmenu_with_kb.sh -p Number -i
)"
NUMBER="$(echo "$NUMBER" | cut -d: -f1 | tr -d -- '- ')"
fi

View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh
err() {
printf %b "$1" | dmenu -c -l 10
printf %b "$1" | dmenu
exit
}

View file

@ -161,8 +161,6 @@ checkforincomingcalls() {
INCOMINGNUMBER="$(cleanupnumber "$INCOMINGNUMBER")"
CONTACTNAME=$(lookupcontactname "$INCOMINGNUMBER")
xset dpms force on
echo "sxmo_modemmonitor: Invoking ring hook (async)">&2
sxmo_hooks.sh ring "$CONTACTNAME" &
@ -188,8 +186,6 @@ checkfornewtexts() {
)"
echo "$TEXTIDS" | grep -v . && return
xset dpms force on
# Loop each textid received and read out the data into appropriate logfile
for TEXTID in $TEXTIDS; do
TEXTDATA="$(mmcli -m "$(modem_n)" -s "$TEXTID" -K)"
@ -321,8 +317,8 @@ mainloop() {
sleep 3
if [ "$TRIES" -eq 10 ]; then
echo failed > "$MODEMSTATEFILE"
echo "sxmo_modemmonitor: forcing modem reset">&2
sxmo_modemmonitortoggle.sh reset #will kill the modemmonitor too
echo "sxmo_modemmonitor: forcing modem restart">&2
sxmo_modemmonitortoggle.sh restart #will kill the modemmonitor too
break
fi
fi

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

View file

@ -6,7 +6,7 @@
err() {
echo "$1">&2
echo "$1" | dmenu -c -l 10
echo "$1" | dmenu
kill $$
}
@ -15,7 +15,7 @@ choosenumbermenu() {
NUMBER="$(
printf %b "\n$icon_cls Cancel\n$icon_grp More contacts\n$(sxmo_contacts.sh | grep -E "^\+?[0-9]+:")" |
awk NF |
sxmo_dmenu_with_kb.sh -p "Number" -l 10 -c -i |
sxmo_dmenu_with_kb.sh -p "Number" -i |
cut -d: -f1 |
tr -d -- '- '
)"
@ -23,7 +23,7 @@ choosenumbermenu() {
NUMBER="$( #joined words without space is not a bug
printf %b "\nCancel\n$(sxmo_contacts.sh --all)" |
grep . |
sxmo_dmenu_with_kb.sh -l 10 -p "Number" -c -i |
sxmo_dmenu_with_kb.sh -p "Number" -i |
cut -d: -f1 |
tr -d -- '- '
)"
@ -57,7 +57,7 @@ sendtextmenu() {
do
CONFIRM="$(
printf %b "$icon_edt Edit\n$icon_snd Send\n$icon_cls Cancel" |
dmenu -c -idx 1 -p "Confirm" -l 10
dmenu -i -p "Confirm"
)" || exit
if echo "$CONFIRM" | grep -q "Send"; then
(sxmo_modemsendsms.sh "$NUMBER" - < "$DRAFT") && \
@ -85,7 +85,7 @@ readtextmenu() {
printf %b "$icon_cls Close Menu\n$icon_edt Send a Text\n";
sxmo_contacts.sh --texted | xargs -IL echo "L logfile"
)"
PICKED="$(printf %b "$ENTRIES" | dmenu -p Texts -c -l 10 -i)" || exit
PICKED="$(printf %b "$ENTRIES" | dmenu -p Texts -i)" || exit
if echo "$PICKED" | grep "Close Menu"; then
exit 1