e5053de6a7
Every effect's sliders and clamps now reach far (a nudge from a tremor to an earthquake, a banner that stays minutes). AGENTS.md documents the file schema, every option and range, the CLI, verification and worked scenarios for scripts and coding agents; attention-required effects prints the catalog as JSON, patch merges keys into a rule, docs prints the guide.
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Plays a sound.
|
|
#
|
|
# Options (set on the effect in rules.json):
|
|
# file path to a sound file; default is the freedesktop "new message" chime
|
|
# intensity volume, 0.0 .. 1.0, default 1 (`volume` works too)
|
|
# speed how many times to play it, default 1 (`repeat` works too)
|
|
set -uo pipefail
|
|
|
|
file=${AR_OPT_FILE:-/usr/share/sounds/freedesktop/stereo/message-new-instant.oga}
|
|
volume=${AR_OPT_INTENSITY:-${AR_OPT_VOLUME:-1}}
|
|
times=${AR_OPT_SPEED:-${AR_OPT_REPEAT:-1}}
|
|
[[ $volume =~ ^[0-9]*\.?[0-9]+$ ]] || volume=1
|
|
[[ $times =~ ^[0-9]+$ ]] || times=1
|
|
(( times > 50 )) && times=50
|
|
file=${file/#\~/$HOME}
|
|
|
|
[[ -r $file ]] || { echo "sound: cannot read $file" >&2; exit 1; }
|
|
|
|
play() {
|
|
if command -v pw-play >/dev/null 2>&1; then
|
|
pw-play --volume="$volume" "$file"
|
|
elif command -v paplay >/dev/null 2>&1; then
|
|
paplay "$file"
|
|
elif command -v mpv >/dev/null 2>&1; then
|
|
mpv --no-video --really-quiet --volume="$(awk -v v="$volume" 'BEGIN { printf "%d", v * 100 }')" "$file"
|
|
else
|
|
echo "sound: no player found (pw-play, paplay or mpv)" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
for ((i = 0; i < times; i++)); do
|
|
play || exit 1
|
|
done
|