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 | ||
6 | $1 == "OK" && \ | |
7 | $2 == "khatus_sensor_devices" && \ | |
8 | $3 == "add" && \ | |
9 | $4 ~ /[0-9]$/ { | |
10 | mount_device($4) | |
11 | } | |
12 | ||
13 | function mount_device(path, cmd, line, lines, line_count, status, i, | |
14 | path_dev, path_mnt) { | |
15 | cmd="udisksctl mount --block-device " path " --no-user-interaction; echo $?" | |
16 | while(cmd | getline line) { | |
17 | lines[++line_count] = line | |
18 | } | |
19 | close(cmd) | |
20 | status = lines[line_count] | |
21 | line_count-- | |
22 | if (status == 0) { | |
23 | for (i=1; i<=line_count; i++) { | |
24 | line = lines[i] | |
25 | if (line ~ /^Mounted /) { | |
26 | split(line, parts, " +") | |
27 | path_dev=parts[2] | |
28 | path_mnt=line | |
29 | sub("^Mounted " path_dev " at ", "", path_mnt) | |
30 | sub("\.$", "", path_mnt) | |
31 | alert("low", "successfully-mounted", path_dev " to " path_mnt) | |
1fb22bdb SK |
32 | if (Execute_On_Mount) { |
33 | system(Execute_On_Mount " '" path_mnt "'") | |
34 | } | |
dffa7e60 SK |
35 | } else { |
36 | alert("hi", "unexpected-success-line", line) | |
37 | } | |
38 | } | |
39 | } else { | |
40 | alert("hi", "failed-to-mount-device", path) | |
41 | } | |
42 | } |