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