diff options
author | EuAndreh <eu@euandre.org> | 2023-04-23 09:12:01 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-23 09:12:01 -0300 |
commit | e24566b9186d578d42749c499dd624ae1052235d (patch) | |
tree | 05ce5016f4f624fc27144a81ff3811f37514ef80 /bin/boop | |
parent | bin/uninclude: Add new utility, with simple tests (diff) | |
download | dotfiles-e24566b9186d578d42749c499dd624ae1052235d.tar.gz dotfiles-e24566b9186d578d42749c499dd624ae1052235d.tar.xz |
bin/boop: Add "-x"option to notify only when COMMAND fails
Diffstat (limited to 'bin/boop')
-rwxr-xr-x | bin/boop | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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" |