summaryrefslogtreecommitdiff
path: root/scripts/nsend
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2024-08-10 13:34:01 +0400
committerSuleyman Farajli <suleyman@farajli.net>2024-08-10 13:34:01 +0400
commit18ea36b1a804c23ecd9fe5867460d56087ab38c7 (patch)
tree32227d8ed25325a8fa13322ae8fe6eb8e6ea07fc /scripts/nsend
parent6032e491056df22807c45bb0c273684981115f56 (diff)
nsend script added
Diffstat (limited to 'scripts/nsend')
-rwxr-xr-xscripts/nsend44
1 files changed, 44 insertions, 0 deletions
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