Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Last active August 29, 2015 14:04
Show Gist options
  • Save romainfrancois/c304c1a59c6d73e9b658 to your computer and use it in GitHub Desktop.
Save romainfrancois/c304c1a59c6d73e9b658 to your computer and use it in GitHub Desktop.
mario beep on OSX
# The code below will probably only work on Linux and requires VLC on the path.
library(beepr)
library(stringr)
play_vlc <- function(fname) {
system(paste("open -a vlc --args --no-loop --no-repeat --playlist-autostart --no-media-library", fname),
ignore.stdout = TRUE, ignore.stderr=TRUE,wait = FALSE)
}
# Plays the mario theme while expr is executing, plays the flag pole jingle when the execution have finished.
# The file "main-theme-overworld.mp3" has to be on the path.
# It can be downloaded from here: https://dl.dropboxusercontent.com/u/5304231/main-theme-overworld.mp3
mario_beep <- function(expr) {
play_vlc( "/tmp/main-theme-overworld.mp3" )
expr
system("osascript -e 'tell application \"vlc\" to quit'")
beep(8)
}
# Use it like this:
mario_beep(Sys.sleep(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment