diff --git a/repertory/repertory/src/ui/mgmt_app_config.cpp b/repertory/repertory/src/ui/mgmt_app_config.cpp index dd5fe84b..27e0a5f5 100644 --- a/repertory/repertory/src/ui/mgmt_app_config.cpp +++ b/repertory/repertory/src/ui/mgmt_app_config.cpp @@ -251,6 +251,34 @@ void mgmt_app_config::set_auto_start(bool auto_start) { fmt::format("failed to remove auto-start entry")); } #endif // defined(_WIN32) + +#if defined(__APPLE__) + auto label = "com.fifthgrid.blockstorage.repertory.ui"; + auto plist_file = utils::file::file{ + utils::path::combine("~", {"/Library/LaunchAgents", label})}; + if (auto_start) { + if (not plist_file.exists()) { + std::vector args = { + utils::path::combine(".", {"repertory"}), + "-ui", + "-lo", + }; + + if (not utils::generate_launchd_plist( + label, utils::path::combine("~", {"/Library/LaunchAgents"}), + args, 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")); + } + } + } else if (not plist_file.remove()) { + utils::error::raise_error( + function_name, utils::get_last_error_code(), + fmt::format("failed to remove auto-start entry")); + } +#endif // defined(__APPLE__) } else { utils::error::raise_error(function_name, utils::get_last_error_code(), fmt::format("failed to change directory"));