aboutsummaryrefslogtreecommitdiff
path: root/bin/msg
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-12 19:00:27 -0300
committerEuAndreh <eu@euandre.org>2022-08-12 19:00:27 -0300
commit6f1a792d88c7c9bcb4d68d5f747e89599e4c6ad4 (patch)
tree71ac66898e811d8bfccb94dc7873215ba4937aef /bin/msg
parentbin/boop: Add optional -m MESSAGE, and use `msg` over playing sound directly (diff)
downloaddotfiles-6f1a792d88c7c9bcb4d68d5f747e89599e4c6ad4.tar.gz
dotfiles-6f1a792d88c7c9bcb4d68d5f747e89599e4c6ad4.tar.xz
bin/msg: Support good and bad messages via -0 and -1
Diffstat (limited to 'bin/msg')
-rwxr-xr-xbin/msg31
1 files changed, 24 insertions, 7 deletions
diff --git a/bin/msg b/bin/msg
index d8ae7fd..ad0b608 100755
--- a/bin/msg
+++ b/bin/msg
@@ -4,7 +4,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- msg [-X|-s|-S|-m|-D|-b] [MESSAGE]
+ msg [-0|-1] [-X|-s|-S|-m|-D|-b] [MESSAGE]
msg -h
EOF
}
@@ -14,20 +14,22 @@ help() {
Options:
-X send MESSAGE using the `xmpp` command
- -s play $XDG_DATA_HOME/msg/medium.ogg sound
+ -s play $XDG_DATA_HOME/msg/{good,bad}.ogg sound
-S say MESSAGE using `speak`
-m send email with MESSAGE as subject and empty body
-D send desktop MESSAGE via `notify-send`
-b print terminal bell
+ -0 an OK message
+ -1 an error message
-h, --help show this message
MESSAGE the text to be sent by the relevant channel
Examples:
- Ring a terminal bell and play a sound:
+ Ring a terminal bell and play a sound, representing an error:
- $ msg -sb
+ $ msg -1sb
Send an email and an XMPP message:
@@ -51,9 +53,14 @@ for flag in "$@"; do
done
sound() {
- play "$XDG_DATA_HOME"/msg/medium.ogg 2>/dev/null
+ if [ "$OK" = true ]; then
+ play "$XDG_DATA_HOME"/msg/good.ogg 2>/dev/null
+ else
+ play "$XDG_DATA_HOME"/msg/bad.ogg 2>/dev/null
+ fi
}
+OK=true
XMPP=false
SOUND=false
SPEAK=false
@@ -62,8 +69,14 @@ DESKTOP=false
BELL=false
ACTION_DONE=false
SHOW_USAGE=false
-while getopts 'XsSmDbh' flag; do
+while getopts '01XsSmDbh' flag; do
case "$flag" in
+ 0)
+ OK=true
+ ;;
+ 1)
+ OK=false
+ ;;
X)
XMPP=true
ACTION_DONE=true
@@ -136,7 +149,11 @@ if [ "$MAIL" = true ]; then
fi
if [ "$DESKTOP" = true ]; then
assert_arg "$MESSAGE" '-D MESSAGE'
- notify-send "$MESSAGE" &
+ if [ "$OK" = true ]; then
+ notify-send -t 5000 "$MESSAGE" &
+ else
+ notify-send -t 5000 -u critical "$MESSAGE" &
+ fi
fi
if [ "$BELL" = true ]; then
printf '\a' &