summaryrefslogtreecommitdiffstats
path: root/share/hooks/notification-irc
blob: 1b4b620dc3e253e467e33f1e5a5bf2d5d06dc0a6 (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
#!/bin/sh

set -e

CONFFILE="${0}.conf"

if echo "${OPTIONS}" | grep -qs "\--no-notification"
then
	exit 0
fi

if  [ ! -e /usr/bin/irk ] || [ ! -r "${CONFFILE}" ]
then
	exit 0
fi

. "${CONFFILE}"

if [ -z "${IRC_CHANNELS}" ]
then
	exit 0
fi

case "${COMMAND}" in
	create|remove|rm|restart|start|stop)
		DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
		HOST="$(hostname -f)"
		USER="${SUDO_USER:-${USER}}"

		for CHANNEL in ${IRC_CHANNELS}
		do
			irk ${CHANNEL} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
		done
		;;
esac