awesomerc: remove useless wibox name
[awesome.git] / lib / beautiful.lua.in
blob7afb59c9f5a6cc91a7ce1981ef7637bfad809212
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 ----------------------------------------------------------------------------
8 -- Grab environment
9 local io = io
10 local print = print
11 local setmetatable = setmetatable
12 local util = require("awful.util")
13 local package = package
14 local capi =
16 screen = screen,
17 awesome = awesome
20 local module_name = "beautiful"
22 --- beautiful: theme library
23 module("beautiful")
25 -- Local data
26 local theme = {}
28 --- Split line in two if it contains the '=' character.
29 -- @param line The line to split.
30 -- @return nil if the '=' character is not in the string
31 local function split_line(line)
32 local split_val = line:find('=')
34 if split_val and line:sub(1, 1) ~= '#' and line:sub(1, 2) ~= '--' then
35 -- Remove spaces and tabulations in key
36 local key = line:sub(1, split_val - 1):gsub(' ', ''):gsub('\t', '')
37 -- and extra spaces and tabulations before value
38 local value = line:sub(split_val + 1, -1)
39 while value:sub(1, 1) == ' ' or value:sub(1, 1) == '\t' do
40 value = value:sub(2, -1)
41 end
43 return key, value
44 end
45 end
47 --- Get a value directly.
48 -- @param key The key.
49 -- @return The value.
50 function __index(self, key)
51 if theme[key] then
52 return theme[key]
53 end
54 end
56 --- Init function, should be runned at the beginning of configuration file.
57 -- @param path The theme file path.
58 function init(path)
59 if path then
60 local f = io.open(path)
62 if not f then
63 return print("E: unable to load theme " .. path)
64 end
66 for line in f:lines() do
67 local key, value
68 key, value = split_line(line)
69 if key then
70 if key == "wallpaper_cmd" then
71 for s = 1, capi.screen.count() do
72 util.spawn(value, s)
73 end
74 elseif key == "font" then
75 capi.awesome.font(value)
76 elseif key == "fg_normal" then
77 capi.awesome.colors({ fg = value })
78 elseif key == "bg_normal" then
79 capi.awesome.colors({ bg = value })
80 end
81 -- Store.
82 theme[key] = value
83 end
84 end
85 f:close()
86 end
87 end
89 setmetatable(package.loaded[module_name], package.loaded[module_name])
91 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80