Skip to content

Instantly share code, notes, and snippets.

View cakcora's full-sized avatar

Cüneyt Gürcan Akçora cakcora

  • University Of Central Florida
  • Orlando, Winnipeg, Dallas, Istanbul
View GitHub Profile
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / theming_rprofile.R
Last active May 15, 2024 15:41
Add to your .Rprofile to change RStudio theme based on hour of the day (dark mode 8pm-6am, light mode 7am-7pm)
# theme options based on hour of day -------------------------------------------
# based on https://github.com/rstudio/rstudio/issues/1579
setHook("rstudio.sessionInit", function(chooseTheme) {
if (chooseTheme) {
if (as.numeric(format(as.POSIXct(Sys.time(), format = "%H:%M:%S"), "%H")) %in% c(0:5, 21:23)) {
if (rstudioapi::getThemeInfo()$editor != "Solarized Dark") rstudioapi::applyTheme("Solarized Dark")
} else {
if (rstudioapi::getThemeInfo()$editor != "Solarized Light") rstudioapi::applyTheme("Solarized Light")
}
}