diff --git a/src/plugin/bridges/common.h b/src/plugin/bridges/common.h index ac264dbb..25047743 100644 --- a/src/plugin/bridges/common.h +++ b/src/plugin/bridges/common.h @@ -321,7 +321,8 @@ class PluginBridge { "Check yabridge's output for more information on what " "went wrong. You may need to rerun your DAW from a " "terminal and restart the plugin scanning process to " - "see the error."); + "see the error.", + true); std::terminate(); } diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index a70c4d21..ebc6395c 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -398,7 +398,9 @@ Configuration load_config_for(const fs::path& yabridge_path) { return Configuration(*config_file, yabridge_path); } -bool send_notification(const std::string& title, const std::string body) { +bool send_notification(const std::string& title, + const std::string body, + bool append_origin) { const fs::path notify_send_path = bp::search_path("notify-send"); if (notify_send_path.empty()) { return false; @@ -410,6 +412,24 @@ bool send_notification(const std::string& title, const std::string body) { std::ostringstream formatted_body; formatted_body << xml_escape(body); + // If possible, append the path to this library file to the message. + if (append_origin) { + try { + const fs::path this_library = get_this_file_location(); + formatted_body + << "\n" + << "Source: " + << xml_escape(this_library.filename().string()) << ""; + } catch (const boost::system::system_error&) { + // I don't think this can fail in the way we're using it, but the + // last thing we want is our notification informing the user of an + // exception to trigger another exception + } + } + try { return bp::system(notify_send_path, "--urgency=normal", "--expire-time=30000", "--app-name=yabridge", title, diff --git a/src/plugin/utils.h b/src/plugin/utils.h index 194f1600..11b80075 100644 --- a/src/plugin/utils.h +++ b/src/plugin/utils.h @@ -274,11 +274,15 @@ Configuration load_config_for(const boost::filesystem::path& yabridge_path); * @param body The message to display. This can contain line feeds, and it any * HTML tags and XML escape sequences will be automatically escaped. The * message can also be empty. + * @param Whether to append 'Source: ' to the body, where `` is + * a hyperlink to the directory this library is placed in. * * @return Whether the notification was sent. This will be false if * `notify-send` is not available. */ -bool send_notification(const std::string& title, const std::string body); +bool send_notification(const std::string& title, + const std::string body, + bool append_origin); /** * Starting from the starting file or directory, go up in the directory diff --git a/src/plugin/vst2-plugin.cpp b/src/plugin/vst2-plugin.cpp index f858b55d..a642e8f5 100644 --- a/src/plugin/vst2-plugin.cpp +++ b/src/plugin/vst2-plugin.cpp @@ -54,7 +54,8 @@ extern "C" VST_EXPORT AEffect* VSTPluginMain( // Also show a desktop notification most people likely won't see the // above message - send_notification("Failed to initialize VST2 plugin", error.what()); + send_notification("Failed to initialize VST2 plugin", error.what(), + true); return nullptr; } diff --git a/src/plugin/vst3-plugin.cpp b/src/plugin/vst3-plugin.cpp index 7ecd7923..3bd609ec 100644 --- a/src/plugin/vst3-plugin.cpp +++ b/src/plugin/vst3-plugin.cpp @@ -57,7 +57,8 @@ bool InitModule() { // Also show a desktop notification most people likely won't see the // above message - send_notification("Failed to initialize VST3 plugin", error.what()); + send_notification("Failed to initialize VST3 plugin", error.what(), + true); return false; }