blob: 405d4060a7230ebf7f3495a4d18d9b20e7625d6b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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 $XDG_DATA_HOME/msg/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 $XDG_DATA_HOME/msg/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
|