Merge branch 'master' of git://github.com/AlexisBRENON/awesome

This commit is contained in:
Uli Schlachter 2015-01-23 21:01:17 +01:00
commit 70bcdef1fd
1 changed files with 17 additions and 9 deletions

View File

@ -72,16 +72,24 @@ function beautiful.get_font_height(name)
end
--- Init function, should be runned at the beginning of configuration file.
-- @param path The theme file path.
function beautiful.init(path)
if path then
-- @param config The theme to load. It can be either the path to the theme file
-- (returning a table) or directly the table containing all the theme values
function beautiful.init(config)
if config 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 config is the path to the theme file,
-- run this file,
-- else if it is the theme table, save it
if type(config) == 'string' then
-- Expand the '~' $HOME shortcut
config = config:gsub("^~/", homedir .. "/")
success, theme = pcall(function() return dofile(config) end)
elseif type(config) == 'table' then
success = true
theme = config
end
if not success then
return print("E: beautiful: error loading theme file " .. theme)
@ -95,10 +103,10 @@ function beautiful.init(path)
if theme.font then set_font(theme.font) end
else
return print("E: beautiful: error loading theme file " .. path)
return print("E: beautiful: error loading theme file " .. config)
end
else
return print("E: beautiful: error loading theme: no path specified")
return print("E: beautiful: error loading theme: no theme specified")
end
end