-
Notifications
You must be signed in to change notification settings - Fork 1
/
notify.sh
executable file
·49 lines (42 loc) · 1.11 KB
/
notify.sh
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
#!/usr/bin/env bash
# -*- coding: UTF-8 -*-
#
## options
## -m, --message <text> Content
## -l, --local Desktop notification
## -r, --remote Mobile notification
# CLInt GENERATED_CODE: start
# info: https://github.com/clobrano/CLInt.git
# No-arguments is not allowed
[ $# -eq 0 ] && sed -ne 's/^## \(.*\)/\1/p' $0 && exit 1
# Converting long-options into short ones
for arg in "$@"; do
shift
case "$arg" in
"--message") set -- "$@" "-m";;
"--local") set -- "$@" "-l";;
"--remote") set -- "$@" "-r";;
*) set -- "$@" "$arg"
esac
done
function print_illegal() {
echo Unexpected flag in command line \"$@\"
}
# Parsing flags and arguments
while getopts 'hlrm:' OPT; do
case $OPT in
h) sed -ne 's/^## \(.*\)/\1/p' $0
exit 1 ;;
l) _local=1 ;;
r) _remote=1 ;;
m) _message=$OPTARG ;;
\?) print_illegal $@ >&2;
echo "---"
sed -ne 's/^## \(.*\)/\1/p' $0
exit 1
;;
esac
done
# CLInt GENERATED_CODE: end
[[ -n ${_local} ]] && notify-send -i "info" "${_message}"
[[ -n ${_remote} ]] && ntfy-send.sh "${_message}"