diff options
| author | EuAndreh <eu@euandre.org> | 2022-05-04 18:57:10 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-05-04 18:57:10 -0300 |
| commit | 1ebad2169f10e19512c9d488dcc4051ebccff514 (patch) | |
| tree | a175283a0147fcbf05b5a7dfd54035e5d9e28439 | |
| parent | ~/.local/bin/xmpp: Add working command! (diff) | |
| download | dotfiles-1ebad2169f10e19512c9d488dcc4051ebccff514.tar.gz dotfiles-1ebad2169f10e19512c9d488dcc4051ebccff514.tar.xz | |
~/.local/bin/msg: Add working version!
| -rwxr-xr-x | .local/bin/msg | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/.local/bin/msg b/.local/bin/msg new file mode 100755 index 00000000..b749c63c --- /dev/null +++ b/.local/bin/msg @@ -0,0 +1,88 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + msg -X XMPP_MESSAGE -s -S SOUND_MESSAGE -m EMAIL -D DESKTOP -b + msg -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -X XMPP_MESSAGE send XMPP using the `xmpp` command + -s play ~/Desktop/medium.ogg sound + -S SOUND_MESSAGE say SOUND_MESSAGE using `speak` + -m EMAIL_SUBJECT send email with EMAIL_SUBJECT and empty body + -D DESKTOP_MESSAGE the desktop message for `notify-send` + -b print terminal bell + -h, --help show this message + EOF +} + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +ACTION_DONE=false +while getopts 'X:sS:m:D:bh' flag; do + case "$flag" in + X) + xmpp -m "$OPTARG" + ACTION_DONE=true + ;; + s) + play ~/Desktop/medium.ogg + ACTION_DONE=true + ;; + S) + echo "$OPTARG" | speak -v pt-BR + ACTION_DONE=true + ;; + m) + echo "" | mail \ + -a 'Content-Type: text/plain; charset=UTF-8' \ + -a 'From:bot@euandre.org' \ + -s "$OPTARG" \ + eu@euandre.org ||: + ACTION_DONE=true + ;; + D) + notify-send "$OPTARG" + ACTION_DONE=true + ;; + b) + printf '\a' + ACTION_DONE=true + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done + +if [ "$ACTION_DONE" = false ]; then + usage + help + exit +fi |
