Ticket #1455: xdg.scm

File xdg.scm, 522 bytes (added by Vasilij Schneidermann, 4 years ago)
Line 
1(define (xdg-path env-variable fallback path)
2  (let ((base (get-environment-variable env-variable)))
3    (if (and base (eqv? (string-ref base 0) #\/))
4        (string-append base path)
5        (string-append fallback path))))
6
7(define (xdg-config-path path)
8  (let ((home (get-environment-variable "HOME")))
9    (xdg-path "XDG_CONFIG_HOME" (string-append home "/.config"))))
10
11(define (xdg-cache-path path)
12  (let ((home (get-environment-variable "HOME")))
13    (xdg-path "XDG_CACHE_HOME" (string-append home "/.cache"))))