- Port Quagr (<=30-byte SHA-256 + XOR + checksum) as C++20 NeoUI DWM plugin quagr.so (xquagr / quagr) across all targets with 3-tab UI (Receive, Send, Config) and independent Rx/Tx Passphrase or Raw 64-Hex key support. - Enforce strict receiver autostart gating in quagr_plugin_init and --preload (starts only when autostart_rx=1 and a valid Rx key/passphrase is set) with atomic $SXMO_NOTIFDIR system notification emission and duress-mode blocking. - Integrate QUAGR/QUAGR_CLEAR full-message wrapped rendering, extended ASCII 5x7 glyphs, persistent hold, and any-side-button dismissal into bananarchy-cover-idle and bananarchy-cover-event.sh for nokia-beatles. - Rebuild and pin a1120 (cocojamboo) images and release archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler, and add scripts/test-quagr.py.
190 lines
5.9 KiB
Bash
Executable File
190 lines
5.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# Bridge Sxmo hooks and cover button call controls to bananarchy-cover-idle.
|
|
# Safe no-op on non-flip devices and when the daemon is not running.
|
|
set -u
|
|
EVENT="${1:-refresh}"
|
|
shift 2>/dev/null || true
|
|
|
|
LID_PROFILE_FILE="${BANANARCHY_LID_PROFILE_FILE:-/usr/share/bananarchy/lid-profile}"
|
|
COVERCTL_BIN="${BANANARCHY_COVERCTL_BIN:-/usr/bin/bananarchy-coverctl}"
|
|
CALLSCREEN_FIFO="${BANANARCHY_CALLSCREEN_FIFO:-/tmp/dwm_plugin_callscreen.fifo}"
|
|
RING_FILE="${BANANARCHY_RINGING_FILE:-/tmp/sxmo_call_ringing}"
|
|
ACTIVE_CALL_FILE="${BANANARCHY_ACTIVE_CALL_FILE:-/tmp/sxmo_active_call}"
|
|
|
|
[ "$(cat "$LID_PROFILE_FILE" 2>/dev/null || true)" = "flip" ] || exit 0
|
|
|
|
coverctl() {
|
|
"$COVERCTL_BIN" "$@"
|
|
}
|
|
|
|
clean_field() {
|
|
printf '%s' "${1:-}" | tr '|\r\n' ' ' | sed 's/^ *//; s/ *$//'
|
|
}
|
|
|
|
is_phone_number() {
|
|
[ -n "${1:-}" ] || return 1
|
|
printf '%s\n' "$1" | grep -q '^[+0-9*#(). -]*$' && \
|
|
printf '%s\n' "$1" | grep -q '[0-9]'
|
|
}
|
|
|
|
lookup_contact_name() {
|
|
raw="$(clean_field "${1:-}")"
|
|
digits="$(printf '%s' "$raw" | tr -cd '0-9')"
|
|
[ "${#digits}" -ge 7 ] || return 0
|
|
cfile="${SXMO_CONTACTFILE:-/home/user/.config/sxmo/contacts.tsv}"
|
|
[ -r "$cfile" ] || return 0
|
|
sfx="${digits#"${digits%???????}"}"
|
|
awk -F '\t' -v d="$digits" -v s="$sfx" '
|
|
NF >= 2 {
|
|
c1 = $1
|
|
gsub(/[^0-9]/, "", c1)
|
|
name = $2
|
|
sub(/\r$/, "", name)
|
|
if (length(c1) >= 7) {
|
|
c1_sfx = substr(c1, length(c1) - 6)
|
|
if (c1 == d || c1_sfx == s) {
|
|
print name
|
|
exit
|
|
}
|
|
}
|
|
}
|
|
' "$cfile" 2>/dev/null || true
|
|
}
|
|
|
|
send_callscreen_fifo() {
|
|
cmd="${1:-}"
|
|
[ -n "$cmd" ] || return 0
|
|
if [ -p "$CALLSCREEN_FIFO" ]; then
|
|
timeout 1 sh -c 'printf "%s\n" "$1" > "$2"' _ "$cmd" "$CALLSCREEN_FIFO" >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
stop_ring_audio() {
|
|
killall -q -TERM bananarchy-melody sxmo_vibrate pw-play mpv 2>/dev/null || true
|
|
rpids="$(pgrep -f '[s]xmo_hook_ring\.sh|[p]w-play.*ring|[m]pv.*ring' 2>/dev/null || true)"
|
|
[ -n "$rpids" ] && kill -TERM $rpids 2>/dev/null || true
|
|
}
|
|
|
|
run_user_cmd() {
|
|
ucmd="$1"
|
|
if [ -n "${BANANARCHY_COVER_TEST_USER_SH:-}" ]; then
|
|
sh -c "$ucmd" >/dev/null 2>&1 || true
|
|
elif [ "$(id -u)" -eq 0 ]; then
|
|
su -s /bin/sh user -c "export HOME=/home/user XDG_RUNTIME_DIR=/run/user/10000 XDG_CONFIG_HOME=/home/user/.config DISPLAY=:0 SXMO_STATE=/run/user/10000/sxmo.state PATH=/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin; $ucmd" </dev/null >/dev/null 2>&1 || true
|
|
else
|
|
sh -c "$ucmd" </dev/null >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
case "$EVENT" in
|
|
notification)
|
|
coverctl NOTIFY "Notification" >/dev/null 2>&1 || true
|
|
;;
|
|
quagr)
|
|
msg="$(clean_field "$*")"
|
|
[ -n "$msg" ] && coverctl QUAGR "$msg" >/dev/null 2>&1 || true
|
|
;;
|
|
quagr-clear|quagr-dismiss)
|
|
coverctl QUAGR_CLEAR >/dev/null 2>&1 || true
|
|
;;
|
|
ring)
|
|
arg1="$(clean_field "${1:-}")"
|
|
sim="$(clean_field "${2:-}")"
|
|
case "$arg1" in
|
|
"[SIM1] "*|"[SIM1]")
|
|
[ -z "$sim" ] && sim="SIM1"
|
|
arg1="$(clean_field "${arg1#"[SIM1]"}")"
|
|
;;
|
|
"[SIM2] "*|"[SIM2]")
|
|
[ -z "$sim" ] && sim="SIM2"
|
|
arg1="$(clean_field "${arg1#"[SIM2]"}")"
|
|
;;
|
|
esac
|
|
num="-"
|
|
name="-"
|
|
if [ -n "$arg1" ] && [ "$arg1" != "-" ]; then
|
|
if is_phone_number "$arg1"; then
|
|
num="$arg1"
|
|
resolved="$(clean_field "$(lookup_contact_name "$num")")"
|
|
[ -n "$resolved" ] && name="$resolved"
|
|
else
|
|
name="$arg1"
|
|
fi
|
|
fi
|
|
[ -n "$sim" ] || sim="-"
|
|
coverctl CALL "incoming|${num}|${name}|${sim}" >/dev/null 2>&1 || true
|
|
;;
|
|
muted)
|
|
num="$(clean_field "${1:--}")"
|
|
name="$(clean_field "${2:--}")"
|
|
sim="$(clean_field "${3:--}")"
|
|
[ -n "$num" ] || num="-"
|
|
[ -n "$name" ] || name="-"
|
|
[ -n "$sim" ] || sim="-"
|
|
coverctl CALL "muted|${num}|${name}|${sim}" >/dev/null 2>&1 || true
|
|
;;
|
|
missed)
|
|
who="$(clean_field "${1:--}")"
|
|
[ -n "$who" ] || who="-"
|
|
coverctl CALL "missed|${who}|-|-" >/dev/null 2>&1 || true
|
|
;;
|
|
call|active)
|
|
num="$(clean_field "${1:--}")"
|
|
name="$(clean_field "${2:--}")"
|
|
sim="$(clean_field "${3:--}")"
|
|
[ -n "$num" ] || num="-"
|
|
[ -n "$name" ] || name="-"
|
|
[ -n "$sim" ] || sim="-"
|
|
coverctl CALL "active|${num}|${name}|${sim}" >/dev/null 2>&1 || true
|
|
;;
|
|
hangup|ended)
|
|
coverctl CALL "none|-|-|-" >/dev/null 2>&1 || true
|
|
;;
|
|
mute-ring)
|
|
stop_ring_audio
|
|
for f in /run/user/10000/sxmo_calls/*.monitoredcall /run/user/10000/sxmo_calls/*.ringing-in; do
|
|
[ -e "$f" ] || continue
|
|
touch "${f%.*}.mutedring" 2>/dev/null || true
|
|
done
|
|
send_callscreen_fifo "MUTE_RING"
|
|
run_user_cmd "sxmo_jobs.sh stop ringing >/dev/null 2>&1 || true; sxmo_hook_mute_ring.sh >/dev/null 2>&1 || true"
|
|
;;
|
|
hangup-call)
|
|
rm -f "$RING_FILE" "$ACTIVE_CALL_FILE" 2>/dev/null || true
|
|
stop_ring_audio
|
|
send_callscreen_fifo "HANGUP_CLOSE"
|
|
if [ -x /usr/libexec/msm-modem-uim-selection ]; then
|
|
timeout 2 /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
|
|
fi
|
|
if command -v mmcli >/dev/null 2>&1; then
|
|
timeout 2 mmcli -m any --voice-hangup-all >/dev/null 2>&1 || true
|
|
fi
|
|
run_user_cmd "sxmo_modemcall.sh hangup all >/dev/null 2>&1 || true; sxmo_hook_discard.sh >/dev/null 2>&1 || true"
|
|
;;
|
|
sms)
|
|
coverctl SMS "${1:-1}" >/dev/null 2>&1 || true
|
|
;;
|
|
screenoff)
|
|
coverctl REFRESH >/dev/null 2>&1 || true
|
|
;;
|
|
network)
|
|
/usr/bin/bananarchy-cover-status.sh >/dev/null 2>&1 || true
|
|
;;
|
|
button)
|
|
# Trusted external side-button wake (also sent directly by
|
|
# bananarchy-volume-keys when the flip is closed).
|
|
coverctl BUTTON >/dev/null 2>&1 || true
|
|
;;
|
|
wake)
|
|
# Every blocked main-panel wake request is forwarded here by the lid gate.
|
|
coverctl WAKE >/dev/null 2>&1 || true
|
|
;;
|
|
refresh|theme)
|
|
coverctl RELOAD_THEME >/dev/null 2>&1 || true
|
|
;;
|
|
*)
|
|
coverctl REFRESH >/dev/null 2>&1 || true
|
|
;;
|
|
esac
|
|
exit 0
|