From: Siraaj Khandkar Date: Sun, 3 Jul 2022 19:22:54 +0000 (-0400) Subject: Convert notify-done alias to notify_done function with more features. X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=58223ee20b98965d7b282e3aca99754bfe66dd2d;p=khome.git Convert notify-done alias to notify_done function with more features. --- 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 \