Last active
April 12, 2016 07:41
-
-
Save emraher/1867e024f74a80a736b1f5981349ed88 to your computer and use it in GitHub Desktop.
Send Growl notifications from R (RStudio, R GUI or R console) - Requires growlnotify / Similar to https://goo.gl/dtP4eH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
growl.notify <- function(msg = "Operation complete") { | |
in.osx <- (Sys.info()['sysname'] == "Darwin") | |
in.rstudio <- (Sys.getenv("RSTUDIO") == "1") | |
in.rgui <- (Sys.getenv("R_GUI_APP_REVISION") != "") | |
dir.notifier <- system("which growlnotify", intern = TRUE) | |
if (in.rstudio) { # hack to see if running in RStudio | |
title <- "RStudio" | |
} | |
if (in.rgui) { # running in R GUI app? | |
title <- "R" | |
} | |
# if running in RStudio or R GUI app use Growl otherwise use message() | |
if ((in.rstudio | in.rgui) & in.osx) { | |
system(paste(dir.notifier, "--appIcon", title, title, "-m '", msg, "'", sep = " "), | |
ignore.stdout = TRUE, ignore.stderr = TRUE, wait = FALSE) | |
} else { | |
message(msg) | |
} | |
} | |
# try it! | |
# if ((Sys.info()['sysname'] == "Darwin")) {devtools::source_gist("1867e024f74a80a736b1f5981349ed88")} | |
# system("sleep 10") | |
# growl.notify("Long op complete") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment