change codename
[awesome.git] / lib / beautiful.lua.in
blob476747d9030639671f34f739db24b728beea6bae
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 io = io
10 local os = os
11 local print = print
12 local pcall = pcall
13 local pairs = pairs
14 local type = type
15 local dofile = dofile
16 local setmetatable = setmetatable
17 local util = require("awful.util")
18 local package = package
19 local capi =
21 screen = screen,
22 awesome = awesome,
23 image = image
26 --- Theme library.
27 module("beautiful")
29 -- Local data
30 local theme
32 --- Init function, should be runned at the beginning of configuration file.
33 -- @param path The theme file path.
34 function init(path)
35 if path then
36 local success
37 success, theme = pcall(function() return dofile(path) end)
39 if not success then
40 return print("E: beautiful: error loading theme file " .. theme)
41 elseif theme then
42 -- try and grab user's $HOME directory
43 local homedir = os.getenv("HOME")
44 -- expand '~'
45 if homedir then
46 for k, v in pairs(theme) do
47 if type(v) == "string" then theme[k] = v:gsub("~", homedir) end
48 end
49 end
51 -- setup wallpaper
52 if theme.wallpaper_cmd then
53 for s = 1, capi.screen.count() do
54 util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s)
55 end
56 end
57 if theme.font then capi.awesome.font = theme.font end
58 if theme.fg_normal then capi.awesome.fg = theme.fg_normal end
59 if theme.bg_normal then capi.awesome.bg = theme.bg_normal end
60 else
61 return print("E: beautiful: error loading theme file " .. path)
62 end
63 else
64 return print("E: beautiful: error loading theme: no path specified")
65 end
66 end
68 --- Get the current theme.
69 -- @return The current theme table.
70 function get()
71 return theme
72 end
74 setmetatable(_M, { __index = function(t, k) return theme[k] end })
76 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80