about summary refs log tree commit diff stats
path: root/bin/notif
diff options
context:
space:
mode:
Diffstat (limited to 'bin/notif')
-rwxr-xr-xbin/notif35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/notif b/bin/notif
new file mode 100755
index 0000000..5e75fd8
--- /dev/null
+++ b/bin/notif
@@ -0,0 +1,35 @@
+#!/bin/sh
+# sends xnotify a notification
+unset TAG SEC
+exec > ${XNOTIFY_FIFO:=$HOME_CACHE/xnotify$DISPLAY.fifo}
+ug_err()
+{
+	echo "${1}" 1>&2 && return "${2:-1}"
+}
+usage()
+{
+	ug_err "usage: ${0##*/} [ -s seconds ] [ -t tag ] <TITLE> [BODY]
+	-s seconds	seconds for notification to live
+	-t tag		category of notification"
+	exit
+}
+while getopts s:t: arg; do
+	case ${arg} in
+	s)	SEC=${OPTARG};;
+	t)	TAG=${OPTARG};;
+	*)	usage;;
+	esac
+done
+if [ -n "$SEC" ]; then
+	printf 'SEC:%s\t' "$SEC"
+	shift 2
+fi
+if [ -n "$TAG" ]; then
+	printf 'TAG:%s\t' "$TAG"
+	shift 2
+fi
+case "$#" in
+	1) printf '%s\n' "$1";;
+	2) printf '%s\t%s\n' "$1" "$2";;
+	*) exit;;
+esac