2 # Typically some file manager (thunar, pcmanfm, etc.), but can be whatever.
3 Execute_On_Mount = Execute_On_Mount ? Execute_On_Mount
: ""
11 msg
["node"] == Node
&& \
12 msg
["module"] ==
"khatus_sensor_devices" && \
13 msg
["type"] ==
"data" && \
14 msg
["key"] ==
"add" && \
15 msg
["val"] ~
/[0-9]$
/ {
16 mount_device
(msg
["val"])
19 function mount_device
(path
, cmd
, line
, lines
, line_count
, status
, i
,
21 cmd=
"udisksctl mount --block-device " path
" --no-user-interaction; echo $?"
22 while(cmd
| getline line
) {
23 lines
[++line_count
] = line
26 status = lines
[line_count
]
29 for (i=
1; i
<=line_count
; i
++) {
31 if (line ~
/^Mounted
/) {
32 split(line
, parts
, " +")
35 sub("^Mounted " path_dev
" at ", "", path_mnt
)
36 sub("\.$", "", path_mnt
)
37 msg_out_alert_low
("successfully-mounted", path_dev
" to " path_mnt
)
38 if (Execute_On_Mount
) {
39 system(Execute_On_Mount
" '" path_mnt
"'")
42 msg_out_alert_hi
("unexpected-success-line", line
)
46 msg_out_alert_hi
("failed-to-mount-device", path
)