sxmo_hook_tailtextlog.sh sxmo
wget https://git.christianimmanuel.de/scripts/raw/sxmo/sxmo_hook_tailtextlog.sh && chmod 740 sxmo_hook_tailtextlog.shsxmo_hook_tailtextlog.sh raw
#!/bin/sh
# configversion: fa6591c65d672647180876bda677e84a
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# This hook displays the sms log for a numbers passed as $1
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
NUMBER="$1"
CONTACTNAME="$(sxmo_contacts.sh | grep ": ${NUMBER}$" | cut -d: -f1)"
[ "???" = "$CONTACTNAME" ] && CONTACTNAME="$CONTACTNAME ($NUMBER)"
TERMNAME="$NUMBER SMS"
export TERMNAME
# If it's already open, switch to it.
if [ "$SXMO_WM" = "sway" ] && [ -z "$SSH_CLIENT" ]; then
regesc_termname="$(echo "$TERMNAME" | sed 's|+|\\+|g')"
swaymsg "[title=\"^$regesc_termname\$\"]" focus && exit 0
fi
export TERM="foot"
sxmo_terminal.sh sh -c "tail -n9999 -f \"$SXMO_LOGDIR/$NUMBER/sms.txt\" | sed \"s/^Received Voice Mail from $NUMBER at \(.*\)-\(.*\)-\(.*\)T\(.*\)+.*$/┌──────────────────────────────────\n│$(tput setaf 3)<- $CONTACTNAME$(tput sgr0) Voice Mail \4 \3.\2.\1/g;s/^Sent \(.*\) \(from\|to\) $NUMBER at \(.*\)-\(.*\)-\(.*\)T\(.*\)+.*$/┌──────────────────────────────────\n│$(tput setaf 2)-> $CONTACTNAME$(tput sgr0) \1 \6 \5.\4.\3/g;s/^Received \(.*\) \(from\|to\) $NUMBER at \(.*\)-\(.*\)-\(.*\)T\(.*\)+.*$/┌──────────────────────────────────\n│$(tput setaf 3)<- $CONTACTNAME$(tput sgr0) \1 \6 \5.\4.\3/g\" "