4 FS = msg_fs ? msg_fs
: "|"
5 OFS = msg_fs ? msg_fs
: "|"
6 Kfs = key_fs ? key_fs
: ":"
7 Module =
"khatus_actuate_device_add_to_automount"
8 # Typically some file manager (thunar, pcmanfm, etc.), but can be whatever.
9 Execute_On_Mount = Execute_On_Mount ? Execute_On_Mount
: ""
13 $
2 ==
"khatus_sensor_devices" && \
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 alert
("low", "successfully-mounted", path_dev
" to " path_mnt
)
38 if (Execute_On_Mount
) {
39 system(Execute_On_Mount
" '" path_mnt
"'")
42 alert
("hi", "unexpected-success-line", line
)
46 alert
("hi", "failed-to-mount-device", path
)
50 function alert
(priority
, subject
, body
) {
51 # priority : "low" | "med" | "hi"
54 print("OK", Module
, "alert", priority
, subject
, body
)