1 ----------------------------------------------------------------------------
2 -- @author Damien Leone <damien.leone@gmail.com>
3 -- @author Julien Danjou <julien@danjou.info>
4 -- @copyright 2008 Damien Leone, Julien Danjou
5 -- @release @AWESOME_VERSION@
6 ----------------------------------------------------------------------------
11 local setmetatable
= setmetatable
12 local util
= require("awful.util")
13 local package
= package
21 local module_name
= "beautiful"
23 --- beautiful: theme library
29 --- Split line in two if it contains the '=' character.
30 -- @param line The line to split.
31 -- @return nil if the '=' character is not in the string
32 local function split_line(line
)
33 local split_val
= line
:find('=')
35 if split_val
and line
:sub(1, 1) ~= '#' and line
:sub(1, 2) ~= '--' then
36 -- Remove spaces and tabulations in key
37 local key
= line
:sub(1, split_val
- 1):gsub(' ', ''):gsub('\t', '')
38 -- and extra spaces and tabulations before value
39 local value
= line
:sub(split_val
+ 1, -1)
40 while value
:sub(1, 1) == ' ' or value
:sub(1, 1) == '\t' do
41 value
= value
:sub(2, -1)
48 --- Get a value directly.
49 -- @param key The key.
51 function __index(self
, key
)
57 --- Init function, should be runned at the beginning of configuration file.
58 -- @param path The theme file path.
61 local f
= io
.open(path
)
64 return print("E: unable to load theme " .. path
)
67 for line
in f
:lines() do
69 key
, value
= split_line(line
)
71 if key
== "wallpaper_cmd" then
72 for s
= 1, capi
.screen
.count() do
75 elseif key
== "font" then
76 capi
.awesome
.font
= value
77 elseif key
== "fg_normal" then
78 capi
.awesome
.fg
= value
79 elseif key
== "bg_normal" then
80 capi
.awesome
.bg
= value
90 --- Get the current theme.
91 -- @return The current theme table.
93 return package
.loaded
[module_name
]
96 setmetatable(package
.loaded
[module_name
], package
.loaded
[module_name
])
98 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80