I run some "set and forget" scripts that take anywhere from a few minutes to an hour to run. While the scripts are running I work on other things, etc...
I would like RStudio to notify me when the scripts are finished running so I can quickly get to analyzing the results. Is there a way to do this?
1 Like
What form of notification did you have in mind ?
A bubble notification (like what I get on email) would be great. Option to get a pop-up would be nice, too. Honestly anything to give me a heads up that my script is done so I don't have to guess.
nwerth
March 29, 2021, 1:14pm
4
I don't have a Mac, so this is untested advice.
You could try using the system2()
function to have the osascript
utility create a notification:
Display Notifications from Terminal on Mac OS – Marduc812
osascript Man Page - macOS - SS64.com
You could also install the terminal-notifier
utility and use that with system2()
:
Send Mac OS Notifications From R | rud.is
1 Like
This sounds like a feature request, if that is actually your intent, I recommend you to file an issue on the GitHub repository for the IDE.
Otherwise, implementing notifications in your own code is the way to go as suggested by @nwerth .
There's an issue to comment on/upvote here:
opened 12:25AM - 28 Nov 18 UTC
enhancement
jobs
Today, if you're running some code in RStudio that might take a while, there's n… o good mechanism for getting notified when it's done. There are a variety of R packages that can help, but the only truly cross-platform solution [emits a simple beep](https://cran.r-project.org/web/packages/beepr/index.html), which isn't much help if you're away from your desk.
RStudio's API could add a method that would show a simple text notification, to be optionally used at the end of a long task. With the appropriate backends, it could show:
- Desktop notifications on MacOS, using `NSUserNotification` or [UserNotifications](https://developer.apple.com/documentation/usernotifications?language=objc)
- [Toast notifications](https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/DesktopToasts) on Windows
- [Freedesktop notifications](https://developer.gnome.org/notification-spec/) on Linux
- [Web Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/notification) on RStudio Server
You could call this API at the end of your R Script to show a custom notification on completion. Optionally, we'd also show you an auto-generated notification:
1. When the IDE does not have focus, and an R command that took more than N seconds has finished executing
2. When a background job (in the Jobs pane) that took more than N seconds has finished
3. When indicated beforehand (gesture TBD) that a notification should be shown after completing the background job or R command about to be executed
Other interesting resources:
- [Notifications from R](https://kbroman.wordpress.com/2014/09/03/notifications-from-r/); blog post discussing approaches in 2014 (beepr, gmailr, rpushbullet)
- [Send OS X notification when done](https://gist.github.com/hrbrmstr/6545433); gist by @hrbrmstr
- [Snorenotify](https://github.com/KDE/snorenotify); multi-platform Qt notification system
2 Likes
system
Closed
April 21, 2021, 10:44pm
7
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.