GithubHelp home page GithubHelp logo

briandconnelly / xdgbasedir Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 23 KB

R implementation of X Desktop Group Base Directory Specification

License: Other

R 100.00%
r rstats xdg xdg-basedir xdg-compliance

xdgbasedir's Introduction

xdgbasedir

Lifecycle: experimental CRAN status R-CMD-check Codecov test coverage

xdgbasedir is R package that allows you to work with paths that comply with the XDG Base Directory Specification.

These functions allow you to get the value associated with the relevant environment variable and to build paths from them:

XDG Variable xdgbasedir function
$XDG_CACHE_HOME path_xdg_cache_home()
$XDG_CONFIG_HOME path_xdg_config_home()
$XDG_DATA_HOME path_xdg_data_home()
$XDG_RUNTIME_DIR path_xdg_runtime_dir()
$XDG_STATE_HOME path_xdg_state_home()

For example, we get the path for storing our configuration file, myconfig.json (on MacOS):

library(xdgbasedir)

path_xdg_config_home("myconfig.json")
#> /Users/bconnelly/.config/myconfig.json

These functions allow you to get an ordered list of directories:

XDG Variable. xdgbasedir function
$XDG_CONFIG_DIRS path_xdg_config_dirs()
$XDG_DATA_DIRS path_xdg_data_dirs()
path_xdg_data_dirs()
#> [1] "/usr/local/share/" "/usr/share/"

Installation

You can install the development version of xdgbasedir like so:

# install.packages("remotes")
remotes::install_github("briandconnelly/xdgbasedir")

Example

Let’s say we wanted to read our RStudio Desktop preferences file, rstudio-prefs.json. Since RStudio complies with the XDG Base Directory Specification, we can easily find that file no matter how the user has configured their environment.

library(xdgbasedir)

prefs_file <- path_xdg_config_home("rstudio-prefs.json")
prefs_file
#> /Users/bconnelly/.config/rstudio-prefs.json

xdgbasedir's People

Contributors

briandconnelly avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.