saturn: Also include DATA_HOME
> $XDG_DATA_DIRS defines the preference-ordered set of base > directories to search for data files in addition to the > $XDG_DATA_HOME base directory. The directories in > $XDG_DATA_DIRS should be seperated with a colon ':'. *in addition to the DATA_HOME base directory*.
This commit is contained in:
parent
c996f99881
commit
5c3644ef2e
@ -94,7 +94,12 @@
|
|||||||
|
|
||||||
(local path {
|
(local path {
|
||||||
:absolute? (fn [str] (= (str:sub 1 1) "/"))
|
:absolute? (fn [str] (= (str:sub 1 1) "/"))
|
||||||
|
:concat (fn [...] (table.concat [...] "/"))
|
||||||
})
|
})
|
||||||
|
(local search-path {
|
||||||
|
:concat (fn [...] (table.concat [...] ":"))
|
||||||
|
})
|
||||||
|
|
||||||
(local Gtk lgi.Gtk)
|
(local Gtk lgi.Gtk)
|
||||||
|
|
||||||
(local GdkPixbuf lgi.GdkPixbuf)
|
(local GdkPixbuf lgi.GdkPixbuf)
|
||||||
@ -154,9 +159,30 @@
|
|||||||
(tset vals "IconImage" (find-icon vals.Icon)))
|
(tset vals "IconImage" (find-icon vals.Icon)))
|
||||||
vals))
|
vals))
|
||||||
|
|
||||||
|
(fn current-user-home []
|
||||||
|
"Returns current user's home directory."
|
||||||
|
(-> (posix.unistd.getuid)
|
||||||
|
(posix.pwd.getpwuid)
|
||||||
|
(. :pw_dir)))
|
||||||
|
|
||||||
|
(fn xdg-data-home []
|
||||||
|
"Provides XDG_DATA_HOME or its default fallback value"
|
||||||
|
(local data-home (os.getenv "XDG_DATA_HOME"))
|
||||||
|
(if data-home
|
||||||
|
data-home
|
||||||
|
(path.concat (current-user-home) ".local/share/")))
|
||||||
|
|
||||||
|
(fn xdg-data-dirs []
|
||||||
|
"Provides all data-dirs as a colon-separated string."
|
||||||
|
;; Expected to be used with gmatch as a generator.
|
||||||
|
(search-path.concat
|
||||||
|
(xdg-data-home)
|
||||||
|
(os.getenv "XDG_DATA_DIRS")
|
||||||
|
))
|
||||||
|
|
||||||
(fn all-apps []
|
(fn all-apps []
|
||||||
(var apps-table {})
|
(var apps-table {})
|
||||||
(each [path (string.gmatch (os.getenv "XDG_DATA_DIRS") "[^:]*")]
|
(each [path (string.gmatch (xdg-data-dirs) "[^:]*")]
|
||||||
(let [apps (.. path "/applications/")]
|
(let [apps (.. path "/applications/")]
|
||||||
(when (lfs.attributes apps)
|
(when (lfs.attributes apps)
|
||||||
(each [f (lfs.dir apps)]
|
(each [f (lfs.dir apps)]
|
||||||
|
Loading…
Reference in New Issue
Block a user