Skip to content

require("lgi").GLib.get_system_data_dirs() returns paths without trailing / #15

Description

@folknor

This is on ubuntu 17.10 running xfce4 git.

Patch to rectify:

diff --git a/lib/lunaconf/xdg.lua b/lib/lunaconf/xdg.lua
index 3061d4c..11a037c 100644
--- a/lib/lunaconf/xdg.lua
+++ b/lib/lunaconf/xdg.lua
@@ -10,9 +10,17 @@ local xdg = {}
 local apps = {}
 local apps_by_id = {}
 
+local function appendSlashes(folder)
+       if not folder:match("/$") then return folder .. "/" end
+       return folder
+end
+
 function xdg.refresh(callback)
        local data_dirs = glib.get_system_data_dirs()
-       table.insert(data_dirs, glib.get_user_data_dir() .. '/')
+       table.insert(data_dirs, glib.get_user_data_dir())
+       for i = 1, #data_dirs do
+               data_dirs[i] = appendSlashes(data_dirs[i])
+       end
        log.info("data_dirs: %s", inspect(data_dirs))
 
        apps = {}

With patch:
aug. 12 19:13:40 edbpc awesome[16707]: data_dirs: { /usr/share/xfce/, /usr/share/xfce4/, /usr/local/share/, /usr/share/, /usr/share/, /home/folk/.local/share/ }

Without patch:
aug. 12 19:06:06 edbpc awesome[15171]: data_dirs: { /usr/share/xfce, /usr/share/xfce4, /usr/local/share/, /usr/share/, /usr/share, /home/folk/.local/share/ }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions