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.
-
Add the dependency to your
shard.yml
:dependencies: xdg_user_dir: github: hugopl/xdg_user_dir.cr
-
Run
shards install
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 😁.
- Fork it (https://github.com/hugopl/xdg_user_dir.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Hugo Parente Lima - creator and maintainer