From dfbaafa4485eb5e965760163dbc1aa5e400e1e5d Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Wed, 15 May 2019 11:23:16 -0400 Subject: [PATCH] Add function to run command and notify on completion --- home/lib/login_functions.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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" +} -- 2.20.1