From f1d05ca51fc4b6198bcdd8fafd172fbe566945b7 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Sat, 10 Aug 2024 13:59:39 +0400 Subject: nsend: updated --- scripts/nsend | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/nsend b/scripts/nsend index 81a852f..b8f9a00 100755 --- a/scripts/nsend +++ b/scripts/nsend @@ -5,8 +5,9 @@ cat << EOF ${0}: Wrapper script to send notifications options: - -s [Msg] Send Msg - -h Print this message and exit + -s [Name] [Msg] Send Msg with Name + -s [Msg] Send Msg Without Name + -h Print this message and exit EOF } @@ -17,25 +18,17 @@ err() { 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}: dunst must be installed" fi case "${1}" in "-s") - [ ${#} != 2 ] && err "${0}: Invalid usage" "Try '${0} -h' for help." + [ ${#} -gt 3 ] && err "${0}: Invalid usage" "Try '${0} -h' for help." + + notify-send "${2}" "${3}" > /dev/null 2>&1 || err "${0}: Failed to send notification" - run "notify-send ${2}" \ - "${0}: Failed to send notification" + exit 0 ;; "-h") help; exit 0 ;; -- cgit v1.2.3