In the context of your runs, the RStudio user preferences (such as
theme) are stored in a file located at
/home/ubuntu/.rstudio/monitored/user-settings/user-settings
. You can
launch RStudio with custom preferences by modifying this file through the
pre-setup script of a custom compute
environment.
If you know the line you must add to the settings file, you can write it directly in the pre-setup script. For example:
mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/
echo 'uiPrefs={"theme" : "Mono Industrial"}' >> /home/ubuntu/.rstudio/monitored/user-settings/user-settings
chown -R ubuntu:ubuntu /home/ubuntu/.rstudio
if [ -f .domino/launch-rstudio-server ]; then
sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server
chown ubuntu:ubuntu .domino/launch-rstudio-server
fi
The following describes what each line is doing:
-
The
mkdir
statement creates the encompassing directory. -
The
echo
statement writes the theme to the file. This can be replaced with a copy operation if you’d prefer to store a file in your project (see next section). -
The
chown
statements are needed to avoid a permissions error. -
The
sed
statement modifies a Domino script that would otherwise overwrite this settings file.
If you aren’t sure which lines to write, or if you want to persist this settings file in your project, you can save a copy in your project and use the following pre-setup script code to apply it to your session.
First, run a session and modify the RStudio preferences to your liking. Before you stop the session, copy the user-settings file to the root of your project directory. You can do so with this line of R code:
file.copy("/home/ubuntu/.rstudio/monitored/user-settings/user-settings", ".")
Then, add the following lines to the pre-setup script of your environment definition, in order to load the preferences file (if it exists) on subsequent runs:
if [ -f user-settings ]; then
mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/
cp user-settings /home/ubuntu/.rstudio/monitored/user-settings
sed -i.bak '/initialWorkingDirectory=/d' /home/ubuntu/.rstudio/monitored/user-settings/user-settings
chown -R ubuntu:ubuntu /home/ubuntu/.rstudio
if [ -f .domino/launch-rstudio-server ]; then
sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server
chown ubuntu:ubuntu .domino/launch-rstudio-server
fi
fi