Ubuntu上のRStudio(ver 1.0.153)の外観をダークテーマに変更する方法をお伝えします。

2017年8月31日時点の安定版RStudioには、外観を変更する機能は搭載されておりません。しかし、daily build版RStudioのには外観をダークにする機能が搭載されるようです。

githubに現在の安定版でもダークテーマに変更する方法を提供されている方がいましたので、今回はこれを用いてダークテーマに変更してみます。

installDarkTheme.shを提供されておりましたが、もう少しだけ手軽かつ元に戻せるようにしたかったので、次のBashスクリプトを作成しました。こちらをchange_theme.shとしてファイルに保存しておきます。


#!/bin/bash

if [ $# -ne 1 ]; then
	echo "Please specify 0 or 1 as argument"
	echo "0: dark -> default / 1: default -> dark"
	exit 1
fi

if [ $1 -eq 0 ]; then
	echo "dark -> default"
	if [ ! -e "/usr/lib/rstudio/vanilla" ]; then
		echo "/usr/lib/rstudio/vanilla was not found"
		exit 1
	fi
	cp -avrf /usr/lib/rstudio/vanilla/index.htm /usr/lib/rstudio/www/index.htm
	cp -avrf /usr/lib/rstudio/vanilla/R.css /usr/lib/rstudio/resources/R.css
	cp -avrf /usr/lib/rstudio/vanilla/gridstyles.css /usr/lib/rstudio/resources/grid/gridstyles.css
	if [ -e "/usr/lib/rstudio/vanilla/custom_styles.css" ]; then
		cp -avrf /usr/lib/rstudio/vanilla/custom_styles.css /usr/lib/rstudio/www/custom_styles.css 
	else
		rm -v /usr/lib/rstudio/www/custom_styles.css
	fi
fi

if [ $1 -eq 1 ]; then
	echo "default -> dark"
	if [ ! -e "/usr/lib/rstudio/vanilla" ]; then
		mkdir -v /usr/lib/rstudio/vanilla
	fi
	cp -avrf /usr/lib/rstudio/www/index.htm /usr/lib/rstudio/vanilla/index.htm
	cp -avrf /usr/lib/rstudio/resources/R.css /usr/lib/rstudio/vanilla/R.css
	cp -avrf /usr/lib/rstudio/resources/grid/gridstyles.css /usr/lib/rstudio/vanilla/gridstyles.css 
	if [ -e "/usr/lib/rstudio/www/custom_styles.css" ]; then
		cp -avrf /usr/lib/rstudio/www/custom_styles.css /usr/lib/rstudio/vanilla/custom_styles.css
	fi

	git clone git://github.com/SWolf23/rstudio-darkTheme /tmp/rstudio-darkTheme
	sudo cp -avrf /tmp/rstudio-darkTheme/index.htm /usr/lib/rstudio/www/index.htm 
	sudo cp -avrf /tmp/rstudio-darkTheme/custom_styles.css /usr/lib/rstudio/www/custom_styles.css 
	sudo cp -avrf /tmp/rstudio-darkTheme/R.css /usr/lib/rstudio/resources/R.css 
	sudo cp -avrf /tmp/rstudio-darkTheme/gridstyles.css /usr/lib/rstudio/resources/grid/gridstyles.css
fi

デフォルトのテーマからダークなテーマへ変更する場合は、次のコマンドを実行します。


$ sudo sh change_theme 1

詳しくは調査しておりませんが、私の環境ではFilesのところが白いままとなっております。

ダークなテーマからデフォルトのテーマへ変更する場合は、次のコマンドを実行します。


$ sudo sh change_theme 0

UbuntuでRStudioの外観をDarkに変更する方法