xdg: adding a XDG Base Directory Specification.

db4
John Benediktsson 2015-11-04 10:24:27 -08:00
parent ca898311cd
commit 21ddb1e305
3 changed files with 31 additions and 0 deletions

1
extra/xdg/authors.txt Normal file
View File

@ -0,0 +1 @@
John Benediktsson

1
extra/xdg/summary.txt Normal file
View File

@ -0,0 +1 @@
XDG Base Directory Specification

29
extra/xdg/xdg.factor Normal file
View File

@ -0,0 +1,29 @@
! Copyright (C) 2015 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: environment sequences splitting ;
IN: xdg
! http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
: xdg-data-home ( -- path )
"XDG_DATA_HOME" os-env [ "~/.local/share" ] when-empty ;
: xdg-config-home ( -- path )
"XDG_CONFIG_HOME" os-env [ "~/.config" ] when-empty ;
: xdg-cache-home ( -- path )
"XDG_CACHE_HOME" os-env [ "~/.cache" ] when-empty ;
: xdg-data-dirs ( -- paths )
"XDG_DATA_DIRS" os-env ":" split harvest
[ { "/usr/local/share" "/usr/share" } ] when-empty ;
: xdg-config-dirs ( -- paths )
"XDG_CONFIG_DIRS" os-env ":" split harvest
[ { "/etc/xdg" } ] when-empty ;
: xdg-runtime-dir ( -- path/f )
"XDG_RUNTIME_DIR" os-env ;
! TODO: check runtime secure permissions