aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-23 09:12:01 -0300
committerEuAndreh <eu@euandre.org>2023-04-23 09:12:01 -0300
commite24566b9186d578d42749c499dd624ae1052235d (patch)
tree05ce5016f4f624fc27144a81ff3811f37514ef80
parentbin/uninclude: Add new utility, with simple tests (diff)
downloaddotfiles-e24566b9186d578d42749c499dd624ae1052235d.tar.gz
dotfiles-e24566b9186d578d42749c499dd624ae1052235d.tar.xz
bin/boop: Add "-x"option to notify only when COMMAND fails
-rwxr-xr-xbin/boop14
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/boop b/bin/boop
index 546c95c..c9e6ff7 100755
--- a/bin/boop
+++ b/bin/boop
@@ -16,6 +16,7 @@ help() {
-m MESSAGE text message of the desktop
notification (default: COMMAND)
-n don't play any sound
+ -x only notify when COMMAND fails
-h, --help show this message
COMMAND the commands to be executed
@@ -51,7 +52,8 @@ for flag in "$@"; do
done
SOUND=-s
-while getopts 'm:nh' flag; do
+SILENT=false
+while getopts 'm:nxh' flag; do
case "$flag" in
m)
MESSAGE="$OPTARG"
@@ -59,6 +61,9 @@ while getopts 'm:nh' flag; do
n)
SOUND=
;;
+ x)
+ SILENT=true
+ ;;
h)
usage
help
@@ -73,6 +78,8 @@ done
shift $((OPTIND - 1))
+CMD="$*"
+
set +e
"$@"
STATUS=$?
@@ -84,7 +91,8 @@ else
N=1
fi
-CMD="$*"
-msg -"$N" -b $SOUND -D "${MESSAGE:-$CMD}"
+if [ "$N" = 1 ] || [ "$SILENT" = false ]; then
+ msg -"$N" -b $SOUND -D "${MESSAGE:-$CMD}"
+fi
exit "$STATUS"