R/macos.R

Defines functions notify_macos

#' @importFrom utils packageName
#' @importFrom processx run

notify_macos <- function(msg, title, image) {

  tn <- system.file(package = packageName(), "macos", "macnotifier")

  bundle_id <- if (Sys.getenv("RSTUDIO", "") == "1") {
    "org.rstudio.RStudio"
  } else {
    "org.r-project.R"
  }

  args <- c(
    "-message", msg,
    "-title", title,
    "-sender", bundle_id,
    if (! is.null(image)) c("-contentImage", normalizePath(image))
  )

  run(tn, args, timeout = 2)

  invisible()
}
gaborcsardi/notifier documentation built on Feb. 10, 2024, 4:44 p.m.