Add a function for sending desktop notifications

This commit is contained in:
Robbert van der Helm
2021-06-22 16:24:39 +02:00
parent 9f52aca451
commit 437a4dc5ec
2 changed files with 27 additions and 0 deletions
+12
View File
@@ -391,3 +391,15 @@ 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) {
try {
return bp::system(bp::search_path("notify-send"), "--urgency=critical",
"--expire-time=20000", "--app-name=yabridge", title,
body) == EXIT_SUCCESS;
} catch (const boost::process::process_error&) {
// We will have printed the message to the terminal anyways, so if the
// user doesn't have libnotify installed we'll just fail silently
return false;
}
}