#' Notify when a function was executed
#'
#' @param msg Message you want to get in the notification. By default: Operation complete
#' @param playSound play sound. Default value: TRUE
#' @examples
#' \dontrun{
#' notify("Jestem hakerem OSX")
#' }
notify <- function(msg = "Operation complete", playSound = T) {
in.osx <- (Sys.info()['sysname'] == "Darwin")
in.rstudio <- (Sys.getenv("RSTUDIO") == "1")
in.rgui <- (Sys.getenv("R_GUI_APP_REVISION") != "")
if (in.rstudio) { # hack to see if running in RStudio
title <- "RStudio"
sender <- activate <- "org.rstudio.RStudio"
}
if (in.rgui) { # running in R GUI app?
title <- "R GUI"
sender <- activate <- "org.R-project.R"
}
# if running in RStudio or R GUI app use NotificationCenter otherwise use message()
if ((in.rstudio | in.rgui) & in.osx) {
system(paste0('osascript -e \'display notification "', msg ,'" with title "', title , '"\''))
} else {
message(msg)
}
if (playSound) {
beepr::beep(3)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.