Commit | Line | Data |
---|---|---|
43e49903 SK |
1 | #! /usr/bin/awk -f |
2 | ||
3 | BEGIN { | |
4 | # Set the correct value as any other AWK variable: | |
5 | # | |
6 | # khatus_actuate_alert_to_notify_send -v display="$CORRECT_DISPLAY" | |
7 | # | |
8 | display = ":0" | |
75b23ff8 SK |
9 | FS = msg_fs ? msg_fs : "|" |
10 | OFS = msg_fs ? msg_fs : "|" | |
11 | Kfs = key_fs ? key_fs : ":" | |
43e49903 SK |
12 | } |
13 | ||
75b23ff8 SK |
14 | $1 == "OK" && \ |
15 | $3 == "alert" { | |
43e49903 | 16 | src = $2 |
75b23ff8 SK |
17 | priority = $4 |
18 | subject = $5 | |
19 | ||
20 | # Not just using $6 for body - because body might contain a character | |
21 | # identical to FS | |
22 | len_line = length($0) | |
23 | len_head = length($1 FS $2 FS $3 FS $4 FS $5 FS) | |
24 | len_body = len_line - len_head | |
25 | body = substr($0, len_head + 1, len_body) | |
43e49903 SK |
26 | |
27 | sep = body ? "\n" : "" | |
28 | body = body sep "--" src | |
29 | urgency = priority | |
30 | sub("hi" , "critical", urgency) | |
31 | sub("med", "normal" , urgency) | |
32 | ||
33 | cmd = \ | |
34 | sprintf(\ | |
35 | "DISPLAY=%s notify-send -u %s %s \" %s\"", | |
36 | display, urgency, subject, body \ | |
37 | ) | |
38 | system(cmd) | |
39 | next | |
40 | } |