#!/bin/sh set -e [ -n "$DEBUG" ] && set -x vol=${BEEP_VOL:-0.5} snd=${BEEP_SND:-$HOME/Music/sounds/miui/} nobel= nonotify= nosnd= while getopts v:s:S:M:i:BNAh opt; do case "$opt" in v) vol=${OPTARG} ;; s) snd=${OPTARG} ;; # S) subject=${OPTARG} ;; # M) message=${OPTARG} ;; # i) icon=${OPTARG} ;; N) nonotify=1 ;; B) nobel=1 ;; A) nosnd=1 ;; h | ?) printf "usage: %s [-h] -- NOTIFY_SEND_ARGS\n" "$(basename "$0")" printf "\n" printf " -v \t volume (default: %s)\n" "${vol}" printf " -s \t sound file (default: %s)\n" "${snd}" printf " -B \t don't sound terminal bell (default: %b)\n" "${nobel}" printf " -N \t don't send notification (default: %b)\n" "${nonotify}" printf " -A \t don't play sound (default: %b)\n" "${nosnd}" printf "\n" exit 2 ;; esac done shift $((OPTIND - 1)) ( echo ${PPID} if [ -z "${nobel}" ]; then if command -v tput >/dev/null; then tput bel & else (printf '\a' | doas tee -a /dev/console) & fi fi if [ -z "${nonotify}" ] && command -v notify-send >/dev/null; then subject=${BEEP_SUB:-📣 beep} message=${BEEP_MSG:-"It's the bell!"} icon=${BEEP_ICN:-"$(iconez -p $PPID | head -n1)"} if [ -z "$*" ]; then notify-send -a beep -u normal -i "${icon}" "${subject}" "${message}" & else notify-send -a beep -u normal -i "${icon}" "$@" & fi fi if [ -z "${nosnd}" ] && command -v paplay >/dev/null; then if [ -d "${snd}" ]; then case "${1}" in done) snd=${snd}/complete.ogg ;; *) snd=${snd}/bell.ogg ;; esac fi paplay \ --property=media.role=event \ --volume="${vol}" \ "${snd}" fi ) &