From 18ea36b1a804c23ecd9fe5867460d56087ab38c7 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Sat, 10 Aug 2024 13:34:01 +0400 Subject: nsend script added --- scripts/nsend | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 scripts/nsend (limited to 'scripts') diff --git a/scripts/nsend b/scripts/nsend new file mode 100755 index 0000000..05a1467 --- /dev/null +++ b/scripts/nsend @@ -0,0 +1,44 @@ +#!/bin/sh + +help() { +cat << EOF +${0}: Wrapper script to send notifications + +options: + -s [Msg] Send Msg + -h Print this message and exit +EOF +} + +err() { + for line in "${@}"; do + echo "${line}" >&2 + done + exit 1 +} + +run() { + if ! ${1} > /dev/null 2>&1; then + err "${2}" + fi + + [ -n "${3}" ] && echo "${3}" + exit 0 +} + +if ! command -v notify-send > /dev/null 2>&1; then + err "${0}: xwallpaper must be installed" +fi + +case "${1}" in +"-s") + [ ${#} != 2 ] && err "${0}: Invalid usage" "Try '${0} -h' for help." + + run "notify-send ${2}" \ + "${0}: Failed to send notification" +;; +"-h") help; exit 0 ;; + +*) err "${0}: Invalid usage" "Try '${0} -h' for help." ;; + +esac -- cgit v1.2.3