diff options
-rwxr-xr-x | bin/boop | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -3,7 +3,7 @@ set -eu usage() { cat <<-'EOF' - boop -- COMMAND... + boop [-m MESSAGE] -- COMMAND... boop -h EOF } @@ -12,6 +12,8 @@ help() { cat <<-'EOF' Options: + -m MESSAGE text message of the desktop + notification (default: COMMAND) -h, --help show this message COMMAND the commands to be executed @@ -19,13 +21,14 @@ help() { Examples: - Play the positive sound: + Play the positive sound, using the command as message: $ boop echo 123 - Fail with the underlying 127 return code: + Fail with the underlying 127 return code with the + message "ERROR": - $ boop ech 123 + $ boop -m ERROR ech 123 EOF } @@ -44,8 +47,11 @@ for flag in "$@"; do esac done -while getopts 'h' flag; do +while getopts 'm:h' flag; do case "$flag" in + m) + MESSAGE="$OPTARG" + ;; h) usage help @@ -66,9 +72,12 @@ STATUS=$? set -e if [ "$STATUS" = 0 ]; then - play "$XDG_DATA_HOME"/msg/good.ogg 2>/dev/null + N=0 else - play "$XDG_DATA_HOME"/msg/bad.ogg 2>/dev/null + N=1 fi +CMD="$@" +msg -"$N" -bs -D "${MESSAGE:-$CMD}" + exit "$STATUS" |