2cebbff00aedfe8afbfb5d25d5e8684deb2fe609
[khatus.git] / src / awk / exe / actuate_alert_to_notify_send.awk
1 BEGIN {
2 # Set the correct value as any other AWK variable:
3 #
4 # khatus_actuate_alert_to_notify_send -v Display="$CORRECT_DISPLAY"
5 #
6 Display = Display ? Display : ":0"
7 }
8
9 $1 == "OK" && \
10 $3 ~ /^alert/ {
11 src = $2
12 key = $3
13 split(key, key_parts, Kfs)
14 priority = key_parts[2]
15 subject = key_parts[3]
16
17 # Not just using $6 for body - because body might contain a character
18 # identical to FS
19 len_line = length($0)
20 len_head = length($1 FS $2 FS $3 FS $4 FS $5 FS)
21 len_body = len_line - len_head
22 body = substr($0, len_head + 1, len_body)
23
24 sep = body ? "\n" : ""
25 body = body sep "--" src
26 urgency = priority
27 sub("hi" , "critical", urgency)
28 sub("med", "normal" , urgency)
29
30 cmd = \
31 sprintf(\
32 "DISPLAY=%s notify-send -u %s %s \" %s\"",
33 Display, urgency, subject, body \
34 )
35 system(cmd)
36 next
37 }
This page took 0.069493 seconds and 3 git commands to generate.