1 ! Copyright (C) 2015 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: environment sequences splitting ;
8 ! http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
10 : xdg-data-home ( -- path )
11 "XDG_DATA_HOME" os-env [ "~/.local/share" ] when-empty ;
13 : xdg-config-home ( -- path )
14 "XDG_CONFIG_HOME" os-env [ "~/.config" ] when-empty ;
16 : xdg-cache-home ( -- path )
17 "XDG_CACHE_HOME" os-env [ "~/.cache" ] when-empty ;
19 : xdg-data-dirs ( -- paths )
20 "XDG_DATA_DIRS" os-env ":" split harvest
21 [ { "/usr/local/share" "/usr/share" } ] when-empty ;
23 : xdg-config-dirs ( -- paths )
24 "XDG_CONFIG_DIRS" os-env ":" split harvest
25 [ { "/etc/xdg" } ] when-empty ;
27 : xdg-runtime-dir ( -- path/f )
28 "XDG_RUNTIME_DIR" os-env ;
29 ! TODO: check runtime secure permissions
31 : xdg-state-dir ( -- path )
32 "XDG_STATE_HOME" os-env [ "~/.local/state" ] when-empty ;