From: Siraaj Khandkar Date: Sat, 25 Aug 2018 18:24:55 +0000 (-0400) Subject: Add execute-on-mount option X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=commitdiff_plain;h=1fb22bdbf04f83c87c91c7e20e26f06b8ba7af62 Add execute-on-mount option mainly to launch a file manager on mount, but potentially anything --- diff --git a/bin/khatus_actuate_device_add_to_automount b/bin/khatus_actuate_device_add_to_automount index 2c30f9f..a1e1448 100755 --- a/bin/khatus_actuate_device_add_to_automount +++ b/bin/khatus_actuate_device_add_to_automount @@ -5,6 +5,8 @@ BEGIN { OFS = msg_fs ? msg_fs : "|" Kfs = key_fs ? key_fs : ":" Module = "khatus_actuate_device_add_to_automount" + # Typically some file manager (thunar, pcmanfm, etc.), but can be whatever. + Execute_On_Mount = Execute_On_Mount ? Execute_On_Mount : "" } $1 == "OK" && \ @@ -33,6 +35,9 @@ function mount_device(path, cmd, line, lines, line_count, status, i, sub("^Mounted " path_dev " at ", "", path_mnt) sub("\.$", "", path_mnt) alert("low", "successfully-mounted", path_dev " to " path_mnt) + if (Execute_On_Mount) { + system(Execute_On_Mount " '" path_mnt "'") + } } else { alert("hi", "unexpected-success-line", line) } diff --git a/sanity_check b/sanity_check index c0d105b..8b7f969 100755 --- a/sanity_check +++ b/sanity_check @@ -13,5 +13,7 @@ >(stdbuf -o L ./bin/khatus_monitor_energy) \ >(stdbuf -o L ./bin/khatus_monitor_errors) \ >(stdbuf -o L ./bin/khatus_monitor_devices) \ - >(stdbuf -o L ./bin/khatus_actuate_device_add_to_automount) \ + >(stdbuf -o L ./bin/khatus_actuate_device_add_to_automount \ + -v Execute_On_Mount=thunar \ + ) \ > /dev/null