commit ef1bb0f84befc7572cd1e3ac086ea93381a4d908 parent 79e1f553347905d243a600961f7159a314f7c578 Author: Jacob R. Edwards <jacob@jacobedwards.org> Date: Sun, 26 Feb 2023 11:27:24 -0800 Add notify script This script provides a simple interface to notifications and can be made to work with different backends in the future. Diffstat:
| A | local/bin/bin/notify | | | 37 | +++++++++++++++++++++++++++++++++++++ |
1 file changed, 37 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/notify b/local/bin/bin/notify @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright 2023 Jacob R. Edwards <jacob@jacobedwards.org> +# This script is meant to provide a standard interface to notifications +# regardless of the underlying system, be it D-Bus, or otherwise. + +usage() { + echo "${1:+error: $1 +}usage: ${0##*/} [-i image] [-v progress] [-u urgency] message" 1>&2 + exit 1 +} + +while test $# -gt 0 +do + case "$1" in + (-i) image="$2"; shift ;; + (-v) value="$2"; shift ;; + (-u) + case "$2" in + (low) level=low ;; + (normal) level=normal ;; + (high) level=critical ;; + (*) usage '-u accepts "low", "normal", or "high"';; + esac + shift ;; + (-*) usage "$1 option unknown" ;; + (*) break ;; + esac + shift +done + +case "$#" in +(1) m="$1" ;; +(*) usage 'No message' ;; +esac + +# The targeted backend is currently dunst(1) +notify-send ${image:+-i "$image"} ${level:+-u "$level"} ${value:+-h int:value:"$value"} "$m"