aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"