diff --git a/repertory/librepertory/include/utils/unix/unix_utils.hpp b/repertory/librepertory/include/utils/unix/unix_utils.hpp index 2510b4d2..3da6cdc3 100644 --- a/repertory/librepertory/include/utils/unix/unix_utils.hpp +++ b/repertory/librepertory/include/utils/unix/unix_utils.hpp @@ -57,13 +57,12 @@ void windows_create_to_unix(const UINT32 &create_options, const UINT32 &granted_access, std::uint32_t &flags, remote::file_mode &mode); #if defined(__APPLE__) -[[nodiscard]] auto -generate_launchd_plist(const std::string &label, std::string plist_path, - const std::vector &args, - const std::string &working_dir = "/tmp", - const std::string &stdout_log = "/tmp/stdout.log", - const std::string &stderr_log = "/tmp/stderr.log") - -> bool; +[[nodiscard]] auto generate_launchd_plist( + const std::string &label, std::string plist_path, + const std::vector &args, bool run_at_load = false, + bool keep_alive = false, const std::string &working_dir = "/tmp", + const std::string &stdout_log = "/tmp/stdout.log", + const std::string &stderr_log = "/tmp/stderr.log") -> bool; [[nodiscard]] auto launchctl_command(std::string_view label, launchctl_type type) -> int; diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index 9b71eda0..91aa2e5a 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -450,7 +450,7 @@ auto fuse_base::mount([[maybe_unused]] std::vector orig_args, if (not utils::generate_launchd_plist( label_, utils::path::combine("~", {"/Library/LaunchAgents"}), - orig_args, utils::path::absolute("."), + orig_args, false, false, utils::path::absolute("."), fmt::format("/tmp/repertory_{}_{}.out", provider_type_to_string(prov), unique_id), fmt::format("/tmp/repertory_{}_{}.err", diff --git a/repertory/librepertory/src/utils/unix/unix_utils.cpp b/repertory/librepertory/src/utils/unix/unix_utils.cpp index abcc8fa0..36fd4a82 100644 --- a/repertory/librepertory/src/utils/unix/unix_utils.cpp +++ b/repertory/librepertory/src/utils/unix/unix_utils.cpp @@ -310,6 +310,7 @@ auto create_daemon(std::function main_func) -> int { #if defined(__APPLE__) auto generate_launchd_plist(const std::string &label, std::string plist_path, const std::vector &args, + bool run_at_load, bool keep_alive, const std::string &working_dir, const std::string &stdout_log, const std::string &stderr_log) -> bool { @@ -349,7 +350,10 @@ auto generate_launchd_plist(const std::string &label, std::string plist_path, dict.append_child("string").text().set(working_dir.c_str()); dict.append_child("key").text().set("KeepAlive"); - dict.append_child("false"); + dict.append_child(keep_alive ? "true" : "false"); + + dict.append_child("key").text().set("RunAtLoad"); + dict.append_child(run_at_load ? "true" : "false"); dict.append_child("key").text().set("StandardOutPath"); dict.append_child("string").text().set(stdout_log.c_str()); diff --git a/repertory/repertory/src/ui/mgmt_app_config.cpp b/repertory/repertory/src/ui/mgmt_app_config.cpp index ac3eee85..519913c7 100644 --- a/repertory/repertory/src/ui/mgmt_app_config.cpp +++ b/repertory/repertory/src/ui/mgmt_app_config.cpp @@ -267,8 +267,8 @@ void mgmt_app_config::set_auto_start(bool auto_start) { if (not utils::generate_launchd_plist( label, utils::path::combine("~", {"/Library/LaunchAgents"}), - args, utils::path::absolute("."), "/tmp/repertory_ui.out", - "/tmp/repertory_ui.err")) { + args, true, false, utils::path::absolute("."), + "/tmp/repertory_ui.out", "/tmp/repertory_ui.err")) { utils::error::raise_error( function_name, utils::get_last_error_code(), fmt::format("failed to create auto-start entry"));