4 n_ignored =
split(opt_ignore_alerts_from
, ignored
, "[ \t\n]+")
5 for (i =
1; i
<= n_ignored
; i
++) {
6 ignored_alert_sources
[ignored
[i
]] =
1
10 /^STATUS_BAR
/ { shift
(); handle_status_bar
(); next }
11 /^ALERT
/ { shift
(); handle_alert
() ; next }
12 /^ERROR
/ { shift
(); handle_error
() ; next }
14 function handle_status_bar
() {
15 system("xsetroot -name \" " $
0 "\" ")
18 function handle_alert
( src
, priority
, subject
, sep
, body
, urgency
, dbg
) {
26 sep = body ?
"\n" : ""
27 body = body sep
"--" src
30 sub("hi" , "critical", urgency
)
31 sub("med", "normal" , urgency
)
33 dbg
["priority"] = priority
34 dbg
["urgency"] = urgency
35 dbg
["subject"] = subject
37 debug
("ALERT properties", dbg
)
39 if (src in ignored_alert_sources
) {
40 debug
("ALERT ignoring from " src
, ignored_alert_sources
)
42 debug
("ALERT sending from " src
, ignored_alert_sources
)
43 notify_send
(urgency
, subject
, body
)
47 function handle_error
() {
48 notify_send
("normal", "Khatus_Error", $
0)
51 function notify_send
(urgency
, subject
, body
, cmd
) {
54 "DISPLAY=%s notify-send -u %s %s \" %s\"",
55 display
, urgency
, subject
, body \
64 function debug
(msg
, data
, sep
, vals
, key
, payload
) {
68 vals =
sprintf("%s%s%s: \"%s\"", vals
, sep
, key
, data
[key
])
71 payload =
sprintf("[%s] [%s] [%s]", pid
, msg
, vals
)
72 print payload
> "/dev/stderr"