R/oink.R

Defines functions oink

Documented in oink

##' Play sound once a long-running pipe has finished
##'
##' ...
##' @param x some input
##' @return the input; function is called for side effects
##' @export
oink <- function(x, what = NULL) {
  if (is.null(what)) {
    if (suppressPackageStartupMessages(require(oblique))) {
      what <- oblique::oblique()
    } else {
      quotes <- suppressWarnings(readLines("http://www.textfiles.com/humor/TAGLINES/cute.say")[5:87])
      what <- sample(quotes, 1)
    }
    cat(what, file = "~/.oinkfile")          
  }
  
  system("cat ~/.oinkfile | say -v Karen && rm ~/.oinkfile")
  x
}
cszang/oink documentation built on May 27, 2019, 12:11 p.m.