From: Siraaj Khandkar Date: Wed, 15 May 2019 15:23:16 +0000 (-0400) Subject: Add function to run command and notify on completion X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=dfbaafa4485eb5e965760163dbc1aa5e400e1e5d;p=khome.git Add function to run command and notify on completion --- diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 1cc5f7f..862e908 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -166,3 +166,16 @@ bt_devs() { | awk '{print $2}' \ | xargs bluetoothctl -- info } + +run() { + stderr="$(mktemp)" + $@ 2> >(tee "$stderr") + code="$?" + urgency='' + case "$code" in + 0) urgency='normal';; + *) urgency='critical' + esac + notify-send -u "$urgency" "Job done: $code" "$(cat $stderr)" + rm "$stderr" +}