Wibox: Rename to drawin
[awesome.git] / lib / beautiful.lua.in
blob222eb1048a9561f5065d28a5ac3b3c22f103c108
1 ----------------------------------------------------------------------------
2 -- @author Damien Leone <damien.leone@gmail.com>
3 -- @author Julien Danjou <julien@danjou.info>
4 -- @copyright 2008-2009 Damien Leone, Julien Danjou
5 -- @release @AWESOME_VERSION@
6 ----------------------------------------------------------------------------
8 -- Grab environment
9 local os = os
10 local print = print
11 local pcall = pcall
12 local pairs = pairs
13 local type = type
14 local dofile = dofile
15 local setmetatable = setmetatable
16 local util = require("awful.util")
17 local capi =
19 screen = screen,
20 awesome = awesome
23 --- Theme library.
24 module("beautiful")
26 -- Local data
27 local theme
29 --- Init function, should be runned at the beginning of configuration file.
30 -- @param path The theme file path.
31 function init(path)
32 if path then
33 local success
34 success, theme = pcall(function() return dofile(path) end)
36 if not success then
37 return print("E: beautiful: error loading theme file " .. theme)
38 elseif theme then
39 -- try and grab user's $HOME directory
40 local homedir = os.getenv("HOME")
41 -- expand '~'
42 if homedir then
43 for k, v in pairs(theme) do
44 if type(v) == "string" then theme[k] = v:gsub("~", homedir) end
45 end
46 end
48 -- setup wallpaper
49 if theme.wallpaper_cmd then
50 for s = 1, capi.screen.count() do
51 util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s)
52 end
53 end
54 if theme.font then capi.awesome.font = theme.font end
55 if theme.fg_normal then capi.awesome.fg = theme.fg_normal end
56 if theme.bg_normal then capi.awesome.bg = theme.bg_normal end
57 else
58 return print("E: beautiful: error loading theme file " .. path)
59 end
60 else
61 return print("E: beautiful: error loading theme: no path specified")
62 end
63 end
65 --- Get the current theme.
66 -- @return The current theme table.
67 function get()
68 return theme
69 end
71 setmetatable(_M, { __index = function(t, k) return theme[k] end })
73 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80