summary refs log tree commit diff
path: root/bin/beep
diff options
context:
space:
mode:
Diffstat (limited to 'bin/beep')
-rwxr-xr-xbin/beep62
1 files changed, 51 insertions, 11 deletions
diff --git a/bin/beep b/bin/beep
index 4d0e16b..4dc53fb 100755
--- a/bin/beep
+++ b/bin/beep
@@ -1,16 +1,56 @@
 #!/bin/sh
+
 vol=${BEEP_VOL:-0.5}
-snd=${BEEP_SND:-$HOME/Music/sounds/miui/complete.ogg}
-subject=${BEEP_SUB:-beep}
-message=${BEEP_MSG:-"<i>ringing the bell...</i>"}
-icon=${BEEP_ICN:-/usr/share/icons/Adwaita/scalable/status/task-due-symbolic.svg}
+snd=${BEEP_SND:-$HOME/Music/sounds/miui/}
+subject=${BEEP_SUB:-Beep}
+message=${BEEP_MSG:-"<i>The bell rang</i>"}
+icon=${BEEP_ICN:-"$(iconez -p $PPID | head -n1)"}
+nobel=
+nonotify=
+while getopts v:s:S:M:i:bNh 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 ;;
+		h | ?)
+			printf "usage: %s [-h] -- NOTIFY_SEND_ARGS\n" "$(basename "$0")"
+			printf "\n"
+			printf "  -v \t volume (default: ${vol})\n"
+			printf "  -s \t sound file (default: ${snd})\n"
+			printf "  -b \t don't sound terminal bell (default: false)\n"
+			printf "  -N \t don't send notification (default: false)\n"
+			printf "\n"
+			exit 2
+			;;
+	esac
+done
+shift $((OPTIND - 1))
+
+(
+	echo ${PPID}
 
-notify-send -a beep -u normal -i "${icon}" \
-	"${subject}" "${message}" &
+	[ -z "${nobel}" ] && tput bel &
 
-tput bel &
+	if [ -z "${nonotify}" ]; then
+		if [ -z "$*" ]; then
+			notify-send -a beep -u normal -i "${icon}" "${subject}" "${message}" &
+		else
+			notify-send -a beep -u normal -i "${icon}" "$@" &
+		fi
+	fi
 
-exec paplay \
-	--property=media.role=event \
-	--volume="${vol}" \
-	"${snd}"
+	if [ ! -f "${snd}" ]; then
+		case "${1}" in
+			done) snd=${snd}/complete.ogg ;;
+			*) snd=${snd}/bell.ogg ;;
+		esac
+	fi
+	paplay \
+		--property=media.role=event \
+		--volume="${vol}" \
+		"${snd}"
+) &