use $XDG_STATE_HOME for battery and sms log
[sxmo-sms-ssh] / .config / sxmo / hooks / sxmo_hook_sms.sh
1 #!/bin/sh
2 # configversion: 72930bc53d64a3cce0338cf500d019a0
3 # SPDX-License-Identifier: AGPL-3.0-only
4 # Copyright 2022 Sxmo Contributors
5
6 # This script is executed after you received a text, mms, or vvm
7 # You can use it to play a notification sound or forward the sms elsewhere
8
9 # The following parameters are provided:
10 # $1 = Contact Name or Number (if number not in contacts)
11 # $2 = Text (or 'VVM' if a vvm)
12 # mms and vvm will include these parameters:
13 # $3 = MMS or VVM payload ID
14 # Finally, mms may include this parameter:
15 # $4 = Group Contact Name or Number (if number not in contacts)
16
17 # shellcheck source=scripts/core/sxmo_common.sh
18 . sxmo_common.sh
19
20 echo $( date +%Y-%m-%dT%H:%M%S ) "SMS $*" >> XDG_STATE_HOME/sms.log     # XXX dpavlin - log sms messages
21
22 if grep "$1" ~user/sms-ssh-number ; then
23         ~/srce02-up.sh
24 fi
25
26 # do nothing if active call
27 if ! sxmo_modemcall.sh list_active_calls | grep -q active; then
28
29         if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.noring ]; then
30                 mpv --no-resume-playback --quiet --no-video "$SXMO_TEXTSOUND" >> /dev/null 2>&1
31         fi
32
33         if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.novibrate ]; then
34                 sxmo_vibrate 500
35         fi
36
37 fi