1 ----------------------------------------------------------------------------
2 -- @author Damien Leone <damien.leone@gmail.com>
3 -- @author Julien Danjou <julien@danjou.info>
4 -- @copyright 2008 Damien Leone, Julien Danjou
5 ----------------------------------------------------------------------------
10 local setmetatable
= setmetatable
11 local awful
= require("awful")
12 local package
= package
13 local capi
= { awesome
= awesome
}
15 local module_name
= "beautiful"
17 --- beautiful: theme library
23 --- Split line in two if it contains the '=' character.
24 -- @param line The line to split.
25 -- @return nil if the '=' character is not in the string
26 local function split_line(line
)
27 local split_val
= line
:find('=')
29 if split_val
and line
:sub(1, 1) ~= '#' and line
:sub(1, 2) ~= '--' then
30 -- Remove spaces in key and extra spaces before value
31 local value
= line
:sub(split_val
+ 1, -1)
32 while value
:sub(1, 1) == ' ' do
33 value
= value
:sub(2, -1)
36 return line
:sub(1, split_val
- 1):gsub(' ', ''), value
40 --- Get a value directly.
41 -- @param key The key.
43 function __index(self
, key
)
49 --- Init function, should be runned at the beginning of configuration file.
50 -- @param path The theme file path.
53 local f
= io
.open(path
)
56 return print("E: unable to load theme " .. path
)
59 for line
in f
:lines() do
61 key
, value
= split_line(line
)
63 if key
== "wallpaper_cmd" then
65 elseif key
== "font" then
66 capi
.awesome
.font_set(value
)
67 elseif key
== "fg_normal" then
68 capi
.awesome
.colors_set({ fg
= value
})
69 elseif key
== "bg_normal" then
70 capi
.awesome
.colors_set({ bg
= value
})
80 setmetatable(package
.loaded
[module_name
], package
.loaded
[module_name
])
82 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80