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.
This commit is contained in:
parent
6280998306
commit
812683e48c
|
@ -72,17 +72,20 @@ end
|
||||||
function beautiful.init(path)
|
function beautiful.init(path)
|
||||||
if path then
|
if path then
|
||||||
local success
|
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)
|
success, theme = pcall(function() return dofile(path) end)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
return print("E: beautiful: error loading theme file " .. theme)
|
return print("E: beautiful: error loading theme file " .. theme)
|
||||||
elseif theme then
|
elseif theme then
|
||||||
-- try and grab user's $HOME directory
|
|
||||||
local homedir = os.getenv("HOME")
|
|
||||||
-- expand '~'
|
-- expand '~'
|
||||||
if homedir then
|
if homedir then
|
||||||
for k, v in pairs(theme) do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue