Forked from mine-cetinkaya-rundel/theming_rprofile.R
Created
February 7, 2020 16:12
-
-
Save sbalci/afb74dd91fdcb0632f5bf8e51427a9a3 to your computer and use it in GitHub Desktop.
Add to your .Rprofile to change RStudio theme based on hour of the day (dark mode 8pm-6am, light mode 7am-7pm)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# theme options based on hour of day ------------------------------------------- | |
# based on https://github.com/rstudio/rstudio/issues/1579 | |
setHook("rstudio.sessionInit", function(chooseTheme) { | |
if (chooseTheme) { | |
if (format(as.POSIXct(Sys.time(), format = "%H:%M:%S"), "%H") %in% c(0:6, 20:23)) { | |
if (rstudioapi::getThemeInfo()$editor != "Solarized Dark") rstudioapi::applyTheme("Solarized Dark") | |
} else { | |
if (rstudioapi::getThemeInfo()$editor != "Solarized Light") rstudioapi::applyTheme("Solarized Light") | |
} | |
} | |
}, | |
action = "replace" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment