Context
I have an R script that takes a long time to run, and I used to run it with beepr::beep()
at the end to notify me when it was finished. I got this idea from, “Is there a way to make R beep/play a sound at the end of a script?”
I would like to run the script using a background job instead so that I can continue to work on other things within the same project. I would still like to be notified (with sound) when the script completes.
The Problem
The problem is that beepr::beep()
does not appear to work for background jobs. Here is an example that reproduces this on my system. This should be in it’s own R script and run as a background job through the RStudio interface.
install.packages("beepr")
library(beepr)
print("About to beep...")
beepr::beep(3)
print("Finshed beeping!")
I can confirm that no sound is played, but the print
statements were visible in the output from the background job.
The following package(s) will be installed:
- beepr [2.0]
These packages will be installed into <path redacted>.
# Installing packages --------------------------------------------------------
- Installing beepr ... OK [linked from cache]
Successfully installed 1 package in 5.4 milliseconds.
[1] "About to beep..."
[1] "Finshed beeping!"
How can I get the script (or RStudio) to notify me (w/ sound) when the background job has completed?
Here is my system/version information:
> version
_
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 3.3
year 2024
month 02
day 29
svn rev 86002
language R
version.string R version 4.3.3 (2024-02-29)
nickname Angel Food Cake
2