summaryrefslogtreecommitdiff
path: root/scripts/gui/nsend
blob: f45cc186bce95d8e22e16289dd3d941f7a015475 (plain)
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
#!/bin/sh

. "lib_common.sh"
. "lib_handle.sh"

help() {
cat << EOF
${progname}: Send notifications
options:
 -s [Msg]        Send Msg
 -t [Time]       Disappear after Time (in second)
 -h              Print this message and exit

Note: time must be between 0 and 300,
by default time is set to unlimited.
EOF
exit 0
}

[ "${#}" -eq 0 ] && invalid_use

time=-1
while getopts "s:t:h" option; do
	case "${option}" in
	s) msg="${OPTARG}"  ;;
	t)
		time="${OPTARG}"

		case "${time}" in
			''|*[!0-9]*) err "Not a number: ${time}" ;;
		esac

		[ "${time}" -gt 300 ] && err "Out of range: ${time}"
	;;
	h) help             ;;

	*) invalid_use -h   ;;
	esac
done

shift $((OPTIND - 1))
[ ${#} != 0 ] && invalid_use

notify_handle send "${time}" "${msg}"