2008-08-05 22:21:22 +02:00
|
|
|
----------------------------------------------------------------------------
|
2008-08-05 22:26:34 +02:00
|
|
|
-- @author Damien Leone <damien.leone@gmail.com>
|
2008-08-05 22:21:22 +02:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008 Damien Leone, Julien Danjou
|
2008-08-18 11:41:58 +02:00
|
|
|
-- @release @AWESOME_VERSION@
|
2008-08-05 22:21:22 +02:00
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment
|
|
|
|
local io = io
|
|
|
|
local print = print
|
|
|
|
local setmetatable = setmetatable
|
2008-09-29 16:49:18 +02:00
|
|
|
local util = require("awful.util")
|
2008-08-05 22:21:22 +02:00
|
|
|
local package = package
|
2008-08-20 18:15:08 +02:00
|
|
|
local capi =
|
|
|
|
{
|
|
|
|
screen = screen,
|
2008-11-09 15:51:43 +01:00
|
|
|
awesome = awesome,
|
|
|
|
image = image
|
2008-08-20 18:15:08 +02:00
|
|
|
}
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2008-11-13 15:26:01 +01:00
|
|
|
--- Theme library
|
2008-08-08 19:07:42 +02:00
|
|
|
module("beautiful")
|
2008-08-05 22:21:22 +02:00
|
|
|
|
|
|
|
-- Local data
|
|
|
|
local theme = {}
|
|
|
|
|
|
|
|
--- Get a value directly.
|
|
|
|
-- @param key The key.
|
|
|
|
-- @return The value.
|
|
|
|
function __index(self, key)
|
2008-11-25 17:47:06 +01:00
|
|
|
return theme[key]
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Init function, should be runned at the beginning of configuration file.
|
|
|
|
-- @param path The theme file path.
|
|
|
|
function init(path)
|
|
|
|
if path then
|
|
|
|
local f = io.open(path)
|
|
|
|
|
|
|
|
if not f then
|
|
|
|
return print("E: unable to load theme " .. path)
|
|
|
|
end
|
|
|
|
|
2008-11-22 08:47:05 +01:00
|
|
|
for key, value in f:read("*all"):gsub("^","\n"):gmatch("\n[\t ]*([a-z_]+)[\t ]*=[\t ]*([^\n\t]+)") do
|
|
|
|
if key == "wallpaper_cmd" then
|
|
|
|
for s = 1, capi.screen.count() do
|
|
|
|
util.spawn(value, s)
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
2008-11-22 08:47:05 +01:00
|
|
|
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
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
2008-11-22 08:47:05 +01:00
|
|
|
-- Store.
|
|
|
|
theme[key] = value
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
2008-08-06 15:37:36 +02:00
|
|
|
f:close()
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-11-13 11:53:41 +01:00
|
|
|
--- Get the current theme.
|
|
|
|
-- @return The current theme table.
|
|
|
|
function get()
|
2008-12-02 15:56:43 +01:00
|
|
|
return _M
|
2008-11-13 11:53:41 +01:00
|
|
|
end
|
|
|
|
|
2008-12-02 15:56:43 +01:00
|
|
|
setmetatable(_M, _M)
|
2008-08-06 15:39:51 +02:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|