aboutsummaryrefslogtreecommitdiff
path: root/bin/msg
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-05-12 12:01:54 -0300
committerEuAndreh <eu@euandre.org>2022-05-12 12:01:54 -0300
commit90eaebabcaaea74237f34cf05709625345f276cc (patch)
tree349e7609d20ecfb6567652a7e28595cec9647eb0 /bin/msg
parent.usr/etc/i3/config: WIP setup extra bindings (diff)
downloaddotfiles-90eaebabcaaea74237f34cf05709625345f276cc.tar.gz
dotfiles-90eaebabcaaea74237f34cf05709625345f276cc.tar.xz
Move Git repository into ~/.usr/.git/
Diffstat (limited to 'bin/msg')
-rwxr-xr-xbin/msg90
1 files changed, 90 insertions, 0 deletions
diff --git a/bin/msg b/bin/msg
new file mode 100755
index 0000000..f3e893e
--- /dev/null
+++ b/bin/msg
@@ -0,0 +1,90 @@
+#!/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
+
+sound() {
+ play ~/Desktop/medium.ogg 2>/dev/null &
+}
+
+ACTION_DONE=false
+while getopts 'X:sS:m:D:bh' flag; do
+ case "$flag" in
+ X)
+ xmpp -m "$OPTARG" eu@euandreh.xyz
+ ACTION_DONE=true
+ ;;
+ s)
+ sound
+ ACTION_DONE=true
+ ;;
+ S)
+ echo "$OPTARG" | speak -v pt-BR
+ ACTION_DONE=true
+ ;;
+ m)
+ echo "" | email -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
+ sound
+ usage
+ help
+fi
+
+wait