Beautiful: Handle invalid wallpaper_cmd better (FS#941)

Biggest plus is that this no longer errors out when wallpaper_cmd isn't a table.
Second biggest plus is that this now prints a warning.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2011-11-27 11:14:25 +01:00
parent 3d4d1955da
commit d3021e6772
1 changed files with 9 additions and 4 deletions

View File

@ -29,11 +29,11 @@ module("beautiful")
-- Local data -- Local data
local theme local theme
local wallpaper = {}
-- Checks the entries in the wallpaper_cmd are valid. -- Checks the entries in the wallpaper_cmd are valid.
-- @param tw A table with wallpaper commands. -- @param tw A table with wallpaper commands.
-- @return False if tw length is zero or if any entries in tw are not strings. -- @return False if there is no way that this can be a valid wallpaper cmd.
function wallpaper.is_valid(tw) local function wallpaper_is_valid(tw)
if type(tw) ~= 'table' then return false end
for _, v in pairs(tw) do for _, v in pairs(tw) do
if type(v) ~= 'string' then return false end if type(v) ~= 'string' then return false end
end end
@ -60,10 +60,15 @@ function init(path)
end end
-- setup wallpaper -- setup wallpaper
if wallpaper.is_valid(theme.wallpaper_cmd) then if wallpaper_is_valid(theme.wallpaper_cmd) then
for s = 1, capi.screen.count() do for s = 1, capi.screen.count() do
util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s) util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s)
end end
else
if theme.wallpaper_cmd then
-- There is a wallpaper_cmd, but wallpaper_is_valid doesn't like it
print("W: beautiful: invalid wallpaper_cmd in theme file " .. path)
end
end end
if theme.font then capi.awesome.font = theme.font end if theme.font then capi.awesome.font = theme.font end
if theme.fg_normal then capi.awesome.fg = theme.fg_normal end if theme.fg_normal then capi.awesome.fg = theme.fg_normal end