Skip to content

A thin wrapper around xdg_user_dir_lookup C function from xdg_user_dir

License

Notifications You must be signed in to change notification settings

hugopl/xdg_user_dir.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XDG User Dir

This is a thin wrapper around xdg_user_dir_lookup C function from xdg-user-dirs, the C code is linked statically and has no dependencies.

This is useful if you don't want to spawn a new process just to fetch some value from xdg-user-dir program.

Maybe in the future I could port the C code to Crystal and let this be pure Crystal, a PR with spec tests are welcome.

If your application uses GLib, the functionality provided by this shard is available in the GLib.html#user_special_dir function.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      xdg_user_dir:
        github: hugopl/xdg_user_dir.cr
  2. Run shards install

Usage

require "xdg_user_dir"

# You can query the default locations in a type safe way
XdgUserDir.lookup(:documents) #=> "/home/joe/Documents"

# Or using a string to access custom locations
XdgUserDir.lookup("MUSIC") #=> "/home/joe/Music"

As you can check in the API docs, it's a single function API shard 😁.

Contributing

  1. Fork it (https://github.com/hugopl/xdg_user_dir.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

A thin wrapper around xdg_user_dir_lookup C function from xdg_user_dir

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project