feat(omo): play omo's own synthesised notification sounds

omo-notify and omo-remote played Apple's Glass and Ping through afplay, which exist only on macOS and are not ours to ship. They now play omo-done (task finished), omo-input (needs your input) and omo-error (stopped with an error), rendered by sfx from .config/omo/sounds/recipes.toml at the same loudness as Glass. The new omo-sound plays a sound by name or any audio file, with afplay on macOS and pw-play, paplay, aplay or ffplay on Linux, and finds the sounds through the dotfiles checkout it is linked from.
This commit is contained in:
David Ibia
2026-10-18 12:56:09 +01:00
parent 5805f45358
commit 66d1d21011
8 changed files with 66 additions and 11 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Play one of omo's notification sounds (omo-done, omo-input, omo-error) or any
# audio file with whatever player this machine has: afplay on macOS, else
# PipeWire, PulseAudio, ALSA or ffplay on Linux. It blocks until playback ends,
# so hooks that must not wait run it in the background.
#
# The sounds are rendered by sfx from .config/omo/sounds/recipes.toml in the
# dotfiles checkout this script is linked from.
#
# Usage: omo-sound NAME|FILE
sound=${1:?usage: omo-sound NAME|FILE}
if [[ ! -f $sound ]]; then
sound="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../../.config/omo/sounds/$sound.wav"
fi
if [[ ! -f $sound ]]; then
echo "omo-sound: no such sound or file: $1" >&2
exit 1
fi
if command -v afplay >/dev/null; then
exec afplay "$sound"
elif command -v pw-play >/dev/null; then
exec pw-play "$sound"
elif command -v paplay >/dev/null; then
exec paplay "$sound"
elif command -v aplay >/dev/null; then
exec aplay -q "$sound"
elif command -v ffplay >/dev/null; then
exec ffplay -nodisp -autoexit -loglevel quiet "$sound"
fi
echo "omo-sound: no audio player found (afplay, pw-play, paplay, aplay or ffplay)" >&2
exit 1