Add RTTTL/eMelody/iMelody ringtones and separate notification/SMS sound config

This commit is contained in:
Luxferre committed 2026-10-30 12:11:16 +02:00
1 parent c766f6c53b
commit 9c28fa1e4c
46 files changed
+2452 -148

No files matched your search

@@ -0,0 +1 @@
/usr/share/sxmo/ringtones/Soft_Bell.wav
@@ -2,3 +2,4 @@ SXMO_RINGTIME=20
SXMO_RINGNUMBER=10
SXMO_VIBRATE_STRENGTH=2
SXMO_RINGVOL=100
SXMO_TEXTSOUND="/usr/share/sxmo/ringtones/Soft_Bell.wav"
@@ -0,0 +1 @@
BananaBounce:d=8,o=5,b=175:g,a,b,d6,16g6,16d6,b,4g,a,b,c6,e6,16a6,16e6,c6,4a,b,d6,g6,f#6,e6,d6,c6,b,a,d6,4f#6,4g6
@@ -0,0 +1 @@
NeonArp:d=16,o=5,b=140,s=c,l=2:a,c6,e6,a6,e6,c6,a,e,g,b,d6,g6,d6,b,g,d,f,a,c6,f6,c6,a,f,c,e,g#,b,e6,4a6
@@ -0,0 +1 @@
Espionage:d=8,o=5,b=150:e,e,16p,e,16p,c,e,4g,4p,4g4,4p,c6,16p,g,16p,e,16p,a,b,16a#,a,g,e6,g6,4a6,f6,g6,16p,e6,c6,d6,4b
@@ -0,0 +1,7 @@
BEGIN:EMELODY
VERSION:1.0
NAME:Nordic Bells
COMPOSER:Bananarchy
BEAT:135
MELODY:a+c+e+Ape+c+aEp(d+f+a+Dpc+e+g+Cp@2)a+e+A
END:EMELODY
@@ -0,0 +1,10 @@
BEGIN:IMELODY
VERSION:1.2
FORMAT:CLASS1.0
NAME:Pocket Chime
COMPOSER:Bananarchy
BEAT:150
STYLE:S0
VOLUME:V14
MELODY:(*5c4*5e4*5g4*6c3r4*5b4*5g4*5d4*5g3r4@2)*5c4*5g4*6c4*6e4*6g2
END:IMELODY
Binary file not shown.
+14 -2
View File
@@ -29,6 +29,7 @@ clear_all() {
_handle_new_notif_file() {
file="$1"
mode="$2"
[ -f "$file" ] || return 0
if [ "$(wc -l < "$file" 2>/dev/null || echo 0)" -lt 3 ]; then
@@ -37,7 +38,9 @@ _handle_new_notif_file() {
return 0
fi
sxmo_hook_notification.sh "$file" &
if [ "$mode" != "boot" ]; then
sxmo_hook_notification.sh "$file" &
fi
group="$(awk NR==1 "$file" 2>/dev/null)"
action="$(awk NR==2 "$file" 2>/dev/null)"
@@ -70,7 +73,7 @@ monitor() {
mkdir -p "$SXMO_NOTIFDIR"
find "$SXMO_NOTIFDIR" -type f 2>/dev/null | while read -r file; do
_handle_new_notif_file "$file"
_handle_new_notif_file "$file" "boot"
done
_notifications_hook
@@ -112,6 +115,7 @@ menu() {
choices="$(cat <<EOF
$icon_del Clear Notifications
$(_menu_lines)
$icon_bel Notification Sound
$icon_cls Close Menu
EOF
)"
@@ -130,6 +134,10 @@ EOF
clear_all
exit
;;
"$icon_bel Notification Sound")
setsid -f xringtones --notif >/dev/null 2>&1
exit
;;
*)
file="$(
printf "%b" "$choices" |
@@ -187,6 +195,10 @@ new() {
mkdir -p "$SXMO_NOTIFDIR"
printf "%s\n%s\n%b\n" "$group" "$action" "$msg" > "$SXMO_NOTIFDIR/$id"
if ! pgrep -f "sxmo_notifs.sh monitor" >/dev/null 2>&1; then
sxmo_hook_notification.sh "$SXMO_NOTIFDIR/$id" &
fi
sxmo_hook_statusbar.sh notifications
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,19 +3,98 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Runs when a notification arrives,
# Runs when a notification arrives in sxmo_notifs.sh (or via sxmo_hook_sms.sh).
# Arguments:
# $1 - The notification file which contains the notification text.
# $1 - Optional notification file path or event context.
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
#if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.novibrate ]; then
# VIBS=5
# VIBI=0
# while [ "$VIBI" -lt "$VIBS" ]; do
# sxmo_vibrate 400 "${SXMO_VIBRATE_STRENGTH:-1}" &
# sleep 0.5
# VIBI="$(echo "$VIBI+1" | bc)"
# done
#fi
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp}"
# Do nothing during an active call or incoming call ring
if [ -f "$RUNTIME_DIR/sxmo_ringing.pid" ]; then
exit 0
fi
if sxmo_modemcall.sh list_active_calls 2>/dev/null | grep -q active; then
exit 0
fi
# Do nothing in DND / busy mode
if [ -f "$RUNTIME_DIR/sxmo.busy" ]; then
exit 0
fi
if [ -f "$XDG_CONFIG_HOME/sxmo/.busy" ]; then
end="$(cat "$XDG_CONFIG_HOME/sxmo/.busy" 2>/dev/null)"
if [ -z "$end" ] || [ "$(date +%s)" -lt "$end" ]; then
exit 0
fi
fi
# Deduplicate simultaneous notification + SMS hook invocations within 1 second
STAMP_FILE="$RUNTIME_DIR/sxmo_notif_alert.stamp"
LOCK_FILE="$RUNTIME_DIR/sxmo_notif_alert.lock"
exec 8>"$LOCK_FILE"
if command -v flock >/dev/null 2>&1; then
flock -n 8 || exit 0
fi
now_ts="$(date +%s)"
if [ -f "$STAMP_FILE" ]; then
last_ts="$(cat "$STAMP_FILE" 2>/dev/null || echo 0)"
case "$last_ts" in
''|*[!0-9]*) last_ts=0 ;;
esac
if [ $((now_ts - last_ts)) -lt 2 ]; then
exit 0
fi
fi
printf '%s\n' "$now_ts" > "$STAMP_FILE"
exec 8>&-
if [ -f "$XDG_CONFIG_HOME/sxmo/ringsettings" ]; then
# shellcheck disable=SC1091
. "$XDG_CONFIG_HOME/sxmo/ringsettings"
fi
NOTIF_SOUND=""
if [ -s "$XDG_CONFIG_HOME/sxmo/notif_sound" ]; then
IFS= read -r NOTIF_SOUND < "$XDG_CONFIG_HOME/sxmo/notif_sound" || true
fi
if [ -z "$NOTIF_SOUND" ]; then
NOTIF_SOUND="${SXMO_TEXTSOUND:-}"
fi
if [ -z "$NOTIF_SOUND" ]; then
if [ -f "/usr/share/sxmo/ringtones/Soft_Bell.wav" ]; then
NOTIF_SOUND="/usr/share/sxmo/ringtones/Soft_Bell.wav"
else
NOTIF_SOUND="/usr/share/sxmo/notify.ogg"
fi
fi
if [ ! -f "$XDG_CONFIG_HOME/sxmo/.noring" ] && [ "$NOTIF_SOUND" != "NONE" ] && [ "$NOTIF_SOUND" != "none" ]; then
case "${SXMO_RINGVOL:-100}" in
''|*[!0-9]*) SXMO_RINGVOL=100 ;;
esac
if [ "$SXMO_RINGVOL" -gt 0 ] && [ -n "$NOTIF_SOUND" ] && [ -f "$NOTIF_SOUND" ]; then
mpv_vol=$(( SXMO_RINGVOL * 130 / 100 ))
notif_ext="$(printf '%s' "${NOTIF_SOUND##*.}" | tr '[:upper:]' '[:lower:]')"
notif_play="$NOTIF_SOUND"
case "$notif_ext" in
nrt|rtttl|rtx|emy|imy)
notif_play="$RUNTIME_DIR/sxmo_monotone_notif.wav"
bananarchy-melody --wav "$NOTIF_SOUND" "$notif_play" >/dev/null 2>&1 || notif_play=""
;;
esac
if [ -n "$notif_play" ] && [ -f "$notif_play" ]; then
mpv --no-config --no-terminal --no-resume-playback --quiet --no-video \
--end=6 --volume-max=150 --volume="$mpv_vol" "$notif_play" >/dev/null 2>&1 &
fi
fi
fi
if [ ! -f "$XDG_CONFIG_HOME/sxmo/.novibrate" ]; then
sxmo_vibrate 500 "${SXMO_VIBRATE_STRENGTH:-2}" &
fi
wait
@@ -150,6 +150,9 @@ finish() {
pkill -TERM -f "pw-play.*$SXMO_RINGTONE" 2>/dev/null || true
pkill -TERM -f "mpv.*$SXMO_RINGTONE" 2>/dev/null || true
fi
pkill -TERM -f "pw-play.*sxmo_monotone_ring.wav" 2>/dev/null || true
pkill -TERM -f "mpv.*sxmo_monotone_ring.wav" 2>/dev/null || true
pkill -TERM -x bananarchy-melody 2>/dev/null || true
pkill -TERM -x sxmo_vibrate 2>/dev/null || true
if ! is_call_picked_up; then
sxmo_audio.sh device apply >/dev/null 2>&1 || true
@@ -202,8 +205,17 @@ EOF
vhelper="$!"
ext="$(printf '%s' "${SXMO_RINGTONE##*.}" | tr '[:upper:]' '[:lower:]')"
play_file="$SXMO_RINGTONE"
use_pw=0
case "$ext" in
nrt|rtttl|rtx|emy|imy)
play_file="$XDG_RUNTIME_DIR/sxmo_monotone_ring.wav"
if bananarchy-melody --wav "$SXMO_RINGTONE" "$play_file" >/dev/null 2>&1; then
command -v pw-play >/dev/null 2>&1 && use_pw=1
else
exit 0
fi
;;
wav|ogg|oga|mp3|flac|aiff|aif)
command -v pw-play >/dev/null 2>&1 && use_pw=1
;;
@@ -216,7 +228,7 @@ EOF
should_stop_ringing && break
amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
pw-play --volume=1.0 "$SXMO_RINGTONE" >/dev/null 2>&1 &
pw-play --volume=1.0 "$play_file" >/dev/null 2>&1 &
rchild="$!"
wait "$rchild" 2>/dev/null
rc="$?"
@@ -238,7 +250,7 @@ EOF
mpv --no-config --no-terminal --no-resume-playback --quiet --vo=null --no-video \
--ao=pipewire,pulse,alsa --audio-channels=stereo --audio-samplerate=48000 \
--volume-max=100 --volume=100 \
--loop="$loops" "$SXMO_RINGTONE" </dev/null >/dev/null 2>&1 &
--loop="$loops" "$play_file" </dev/null >/dev/null 2>&1 &
rchild="$!"
wait "$rchild" 2>/dev/null || true
rchild=""
@@ -3,50 +3,12 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# This script is executed after you received a text, mms, or vvm
# You can use it to play a notification sound or forward the sms elsewhere
# The following parameters are provided:
# $1 = Contact Name or Number (if number not in contacts)
# $2 = Text (or 'VVM' if a vvm)
# mms and vvm will include these parameters:
# $3 = MMS or VVM payload ID
# Finally, mms may include this parameter:
# $4 = Group Contact Name or Number (if number not in contacts)
# This script is executed after receiving a text, mms, or vvm.
# It delegates to sxmo_hook_notification.sh so SMS and system notifications
# share the configured Notification / SMS sound (~/.config/sxmo/notif_sound)
# and vibration settings without playing duplicate alerts.
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# do nothing if active call
if sxmo_modemcall.sh list_active_calls | grep -q active; then
exit
fi
# do nothing if silent mode
if [ -f "$XDG_CONFIG_HOME"/sxmo/.busy ]; then
end="$(cat "$XDG_CONFIG_HOME"/sxmo/.busy)"
if [ -z "$end" ] || [ "$(date +%s)" -lt "$end" ]; then
exit
fi
fi
if [ -f "$XDG_CONFIG_HOME/sxmo/ringsettings" ]; then
# shellcheck disable=SC1091
. "$XDG_CONFIG_HOME/sxmo/ringsettings"
fi
if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.noring ]; then
case "${SXMO_RINGVOL:-100}" in
''|*[!0-9]*) SXMO_RINGVOL=100 ;;
esac
if [ "$SXMO_RINGVOL" -gt 0 ]; then
mpv_vol=$(( SXMO_RINGVOL * 130 / 100 ))
mpv --no-resume-playback --quiet --no-video --volume-max=150 --volume="$mpv_vol" "$SXMO_TEXTSOUND" >> /dev/null 2>&1 &
fi
fi
if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.novibrate ]; then
sxmo_vibrate 500 "${SXMO_VIBRATE_STRENGTH:-2}" &
fi
wait
exec sxmo_hook_notification.sh --sms "$@"
@@ -0,0 +1 @@
Bananarchy:d=8,o=5,b=160:c,e,g,c6,16e6,16c6,g,4e,d,f,a,d6,16f6,16d6,b,4g,c6,b,a,g,f,e,d,c,16e,16g,16c6,16e6,4g6,8p,4c6
@@ -0,0 +1 @@
CyberMatrix:d=16,o=5,b=150,s=n,l=2:e,g,b,e6,d6,b,g,e,c,e,g,c6,b,g,e,c,d,f#,a,d6,c6,a,f#,d,8e,8p,e,b,8e6,b=170,e6,g6,b6,4e7
@@ -0,0 +1,7 @@
BEGIN:EMELODY
VERSION:1.0
NAME:Ericsson Cascade
COMPOSER:Bananarchy
BEAT:140
MELODY:e+c+bgEgp+d+bafDfp(+cbagfedc@2)+C
END:EMELODY
@@ -0,0 +1,10 @@
BEGIN:IMELODY
VERSION:1.2
FORMAT:CLASS1.0
NAME:IrDA Pager
COMPOSER:Bananarchy
BEAT:160
STYLE:S0
VOLUME:V13
MELODY:*5e4*5e4r4*5e4r4*5c4*5e3*5g2r2*4g2r2(*5c3r4*4g3r4*4e3*4a3*4b3&b4*4a3@2)*5c2
END:IMELODY
@@ -0,0 +1 @@
NokiaVals:d=4,o=5,b=225:8e6,8d6,f#,g#,8c#6,8b,d,e,8b,8a,c#,e,2a,8p,8e6,8d6,f#,g#,8c#6,8b,d,e,8b,8a,c#,e,2a