beautiful: theme are now handled in Lua

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
perry 2009-04-28 19:40:14 +02:00 committed by Julien Danjou
parent f2c104ba78
commit 5e284c4ab3
3 changed files with 28 additions and 24 deletions

View File

@ -275,13 +275,11 @@ set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
# }}} # }}}
# {{{ Configure files # {{{ Configure files
file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in) file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in ${SOURCE_DIR}/themes/*/*.lua.in)
set(AWESOME_CONFIGURE_FILES set(AWESOME_CONFIGURE_FILES
${awesome_lua_configure_files} ${awesome_lua_configure_files}
config.h.in config.h.in
awesomerc.lua.in awesomerc.lua.in
themes/default/theme.in
themes/sky/theme.in
awesome-version-internal.h.in awesome-version-internal.h.in
awesome.doxygen.in) awesome.doxygen.in)

View File

@ -8,9 +8,9 @@ require("naughty")
-- {{{ Variable definitions -- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers -- Themes define colours, icons, and wallpapers
-- The default is a dark theme -- The default is a dark theme
theme_path = "@AWESOME_THEMES_PATH@/default/theme" theme_path = "@AWESOME_THEMES_PATH@/default/theme.lua"
-- Uncommment this for a lighter theme -- Uncommment this for a lighter theme
-- theme_path = "@AWESOME_THEMES_PATH@/sky/theme" -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme.lua"
-- Actually load theme -- Actually load theme
beautiful.init(theme_path) beautiful.init(theme_path)

View File

@ -9,6 +9,9 @@
local io = io local io = io
local os = os local os = os
local print = print local print = print
local pairs = pairs
local type = type
local dofile = dofile
local setmetatable = setmetatable local setmetatable = setmetatable
local util = require("awful.util") local util = require("awful.util")
local package = package local package = package
@ -36,29 +39,32 @@ end
-- @param path The theme file path. -- @param path The theme file path.
function init(path) function init(path)
if path then if path then
local f = io.open(path) theme = dofile(path)
if not f then if theme then
return print("E: unable to load theme " .. path) -- 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
end
end end
for key, value in f:read("*all"):gsub("^", "\n"):gmatch("\n[\t ]*([a-z_]+)[\t ]*=[\t ]*([^\n\t]+)") do -- setup wallpaper
value = value:gsub("~", os.getenv("HOME")) if theme.wallpaper_cmd then
if key == "wallpaper_cmd" then
for s = 1, capi.screen.count() do for s = 1, capi.screen.count() do
util.spawn(value, false, s) util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s)
end end
elseif key == "font" then
capi.awesome.font = value
elseif key == "fg_normal" then
capi.awesome.fg = value
elseif key == "bg_normal" then
capi.awesome.bg = value
end end
-- Store. if theme.font then capi.awesome.font = theme.font end
theme[key] = value if theme.fg_normal then capi.awesome.fg = theme.fg_normal end
if theme.bg_normal then capi.awesome.bg = theme.bg_normal end
else
return print("E: error loading theme file " .. path)
end end
f:close() else
return print("E: error loading theme: no path specified " )
end end
end end