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
|
|
|
|
local awful = require("awful")
|
|
|
|
local package = package
|
|
|
|
local capi = { awesome = awesome }
|
|
|
|
|
|
|
|
local module_name = "beautiful"
|
|
|
|
|
|
|
|
--- beautiful: theme library
|
2008-08-08 19:07:42 +02:00
|
|
|
module("beautiful")
|
2008-08-05 22:21:22 +02:00
|
|
|
|
|
|
|
-- Local data
|
|
|
|
local theme = {}
|
|
|
|
|
|
|
|
--- Split line in two if it contains the '=' character.
|
|
|
|
-- @param line The line to split.
|
|
|
|
-- @return nil if the '=' character is not in the string
|
|
|
|
local function split_line(line)
|
|
|
|
local split_val = line:find('=')
|
|
|
|
|
|
|
|
if split_val and line:sub(1, 1) ~= '#' and line:sub(1, 2) ~= '--' then
|
2008-08-07 08:18:58 +02:00
|
|
|
-- Remove spaces in key and extra spaces before value
|
|
|
|
local value = line:sub(split_val + 1, -1)
|
|
|
|
while value:sub(1, 1) == ' ' do
|
|
|
|
value = value:sub(2, -1)
|
|
|
|
end
|
|
|
|
|
|
|
|
return line:sub(1, split_val - 1):gsub(' ', ''), value
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Get a value directly.
|
|
|
|
-- @param key The key.
|
|
|
|
-- @return The value.
|
|
|
|
function __index(self, key)
|
|
|
|
if theme[key] then
|
|
|
|
return theme[key]
|
|
|
|
end
|
|
|
|
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
|
|
|
|
|
|
|
|
for line in f:lines() do
|
|
|
|
local key, value
|
|
|
|
key, value = split_line(line)
|
|
|
|
if key then
|
|
|
|
if key == "wallpaper_cmd" then
|
|
|
|
awful.spawn(value)
|
|
|
|
elseif key == "font" then
|
|
|
|
capi.awesome.font_set(value)
|
|
|
|
elseif key == "fg_normal" then
|
|
|
|
capi.awesome.colors_set({ fg = value })
|
|
|
|
elseif key == "bg_normal" then
|
|
|
|
capi.awesome.colors_set({ bg = value })
|
|
|
|
end
|
|
|
|
-- Store.
|
|
|
|
theme[key] = value
|
|
|
|
end
|
|
|
|
end
|
2008-08-06 15:37:36 +02:00
|
|
|
f:close()
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
setmetatable(package.loaded[module_name], package.loaded[module_name])
|
2008-08-06 15:39:51 +02:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|