Convert notify-done alias to notify_done function with more features.
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 3 Jul 2022 19:22:54 +0000 (15:22 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 3 Jul 2022 19:22:54 +0000 (15:22 -0400)
home/lib/login_aliases.sh
home/lib/login_functions.sh

index f335f56..4f0fcbf 100644 (file)
@@ -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'
index 3a21209..3bf7676 100644 (file)
@@ -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 \
This page took 0.031025 seconds and 4 git commands to generate.