Commit | Line | Data |
---|---|---|
dffa7e60 | 1 | BEGIN { |
1fb22bdb SK |
2 | # Typically some file manager (thunar, pcmanfm, etc.), but can be whatever. |
3 | Execute_On_Mount = Execute_On_Mount ? Execute_On_Mount : "" | |
dffa7e60 SK |
4 | } |
5 | ||
8482fea6 | 6 | $1 == Node && \ |
dffa7e60 | 7 | $2 == "khatus_sensor_devices" && \ |
8482fea6 SK |
8 | $3 == "data" && \ |
9 | $4 == "add" && \ | |
10 | $5 ~ /[0-9]$/ { | |
11 | mount_device($5) | |
dffa7e60 SK |
12 | } |
13 | ||
14 | function mount_device(path, cmd, line, lines, line_count, status, i, | |
15 | path_dev, path_mnt) { | |
16 | cmd="udisksctl mount --block-device " path " --no-user-interaction; echo $?" | |
17 | while(cmd | getline line) { | |
18 | lines[++line_count] = line | |
19 | } | |
20 | close(cmd) | |
21 | status = lines[line_count] | |
22 | line_count-- | |
23 | if (status == 0) { | |
24 | for (i=1; i<=line_count; i++) { | |
25 | line = lines[i] | |
26 | if (line ~ /^Mounted /) { | |
27 | split(line, parts, " +") | |
28 | path_dev=parts[2] | |
29 | path_mnt=line | |
30 | sub("^Mounted " path_dev " at ", "", path_mnt) | |
31 | sub("\.$", "", path_mnt) | |
8482fea6 | 32 | msg_out_alert_low("successfully-mounted", path_dev " to " path_mnt) |
1fb22bdb SK |
33 | if (Execute_On_Mount) { |
34 | system(Execute_On_Mount " '" path_mnt "'") | |
35 | } | |
dffa7e60 | 36 | } else { |
8482fea6 | 37 | msg_out_alert_hi("unexpected-success-line", line) |
dffa7e60 SK |
38 | } |
39 | } | |
40 | } else { | |
8482fea6 | 41 | msg_out_alert_hi("failed-to-mount-device", path) |
dffa7e60 SK |
42 | } |
43 | } |