From 58223ee20b98965d7b282e3aca99754bfe66dd2d Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Sun, 3 Jul 2022 15:22:54 -0400 Subject: [PATCH] Convert notify-done alias to notify_done function with more features. --- home/lib/login_aliases.sh | 1 - home/lib/login_functions.sh | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/home/lib/login_aliases.sh b/home/lib/login_aliases.sh index f335f56..4f0fcbf 100644 --- a/home/lib/login_aliases.sh +++ b/home/lib/login_aliases.sh @@ -25,4 +25,3 @@ alias ideas='cd ~/doc/ideas && vim ideas.md' alias quotes='cd ~/doc/quotations && vim quotations.md' alias bitcoin='nc ticker.bitcointicker.co 10080' # https://github.com/chubin/awesome-console-services#Money alias weather='cat ~/.pista-out/weather-summary' -alias notify-done='s="$?"; if [[ "$s" -eq 0 ]]; then notify-send "done OK: $s"; else notify-send -u critical "done ERROR: $s"; fi' diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 3a21209..3bf7676 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -1,5 +1,20 @@ # +## notify_done : unit -> unit +notify_done() { + local -r _status_code="$?" + local -r _program="$1" + local _timestamp + _timestamp="$(timestamp)" + local -r _msg="$_timestamp [$_program] done " + if [[ "$_status_code" -eq 0 ]] + then + notify-send -u normal "$_msg OK: $_status_code" + else + notify-send -u critical "$_msg ERROR: $_status_code" + fi +} + ## p : string -> unit p() { awk \ -- 2.20.1