Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
folknor opened this issue Aug 12, 2017 · 0 comments

Comments

@folknor
Copy link

folknor commented Aug 12, 2017

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/ }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant