From 812683e48c748d1e4e57b0725a8f2b24f90d5ff1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 24 Mar 2014 01:10:45 +0100 Subject: [PATCH] Expand '~' in the path for beautiful.init This expands the tilde in the path to beautiful.init and changes the expansion in theme values to only match '^~/': tilde expansion is only meant to be expanded at the beginning. The latter is not really tested. --- lib/beautiful.lua.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/beautiful.lua.in b/lib/beautiful.lua.in index b6147d44..b1c09cf4 100644 --- a/lib/beautiful.lua.in +++ b/lib/beautiful.lua.in @@ -72,17 +72,20 @@ end function beautiful.init(path) if path then local success + + -- try and grab user's $HOME directory and expand '~' + local homedir = os.getenv("HOME") + path = path:gsub("^~/", homedir .. "/") + success, theme = pcall(function() return dofile(path) end) if not success then return print("E: beautiful: error loading theme file " .. theme) elseif theme then - -- try and grab user's $HOME directory - local homedir = os.getenv("HOME") -- expand '~' if homedir then for k, v in pairs(theme) do - if type(v) == "string" then theme[k] = v:gsub("~", homedir) end + if type(v) == "string" then theme[k] = v:gsub("^~/", homedir .. "/") end end end