2008-08-05 22:21:22 +02:00
|
|
|
----------------------------------------------------------------------------
|
2008-08-05 22:26:34 +02:00
|
|
|
-- @author Damien Leone <damien.leone@gmail.com>
|
2008-08-05 22:21:22 +02:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
2009-04-18 16:05:18 +02:00
|
|
|
-- @copyright 2008-2009 Damien Leone, Julien Danjou
|
2008-08-18 11:41:58 +02:00
|
|
|
-- @release @AWESOME_VERSION@
|
2008-08-05 22:21:22 +02:00
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment
|
|
|
|
local io = io
|
2009-04-18 16:05:18 +02:00
|
|
|
local os = os
|
2008-08-05 22:21:22 +02:00
|
|
|
local print = print
|
2009-04-28 19:40:14 +02:00
|
|
|
local pairs = pairs
|
|
|
|
local type = type
|
|
|
|
local dofile = dofile
|
2008-08-05 22:21:22 +02:00
|
|
|
local setmetatable = setmetatable
|
2008-09-29 16:49:18 +02:00
|
|
|
local util = require("awful.util")
|
2008-08-05 22:21:22 +02:00
|
|
|
local package = package
|
2008-08-20 18:15:08 +02:00
|
|
|
local capi =
|
|
|
|
{
|
|
|
|
screen = screen,
|
2008-11-09 15:51:43 +01:00
|
|
|
awesome = awesome,
|
|
|
|
image = image
|
2008-08-20 18:15:08 +02:00
|
|
|
}
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2008-11-13 15:26:01 +01:00
|
|
|
--- Theme library
|
2008-08-08 19:07:42 +02:00
|
|
|
module("beautiful")
|
2008-08-05 22:21:22 +02:00
|
|
|
|
|
|
|
-- Local data
|
|
|
|
local theme = {}
|
|
|
|
|
|
|
|
--- Get a value directly.
|
|
|
|
-- @param key The key.
|
|
|
|
-- @return The value.
|
|
|
|
function __index(self, key)
|
2008-11-25 17:47:06 +01:00
|
|
|
return theme[key]
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Init function, should be runned at the beginning of configuration file.
|
|
|
|
-- @param path The theme file path.
|
|
|
|
function init(path)
|
|
|
|
if path then
|
2009-04-28 19:40:14 +02:00
|
|
|
theme = dofile(path)
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2009-04-28 19:40:14 +02:00
|
|
|
if theme then
|
|
|
|
-- try and grab user's $HOME directory
|
|
|
|
local homedir = os.getenv("HOME")
|
|
|
|
-- expand '~'
|
|
|
|
if homedir then
|
|
|
|
for k, v in pairs(theme) do
|
|
|
|
if type(v) == "string" then theme[k] = v:gsub("~", homedir) end
|
|
|
|
end
|
|
|
|
end
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2009-04-28 19:40:14 +02:00
|
|
|
-- setup wallpaper
|
|
|
|
if theme.wallpaper_cmd then
|
2008-11-22 08:47:05 +01:00
|
|
|
for s = 1, capi.screen.count() do
|
2009-04-28 19:40:14 +02:00
|
|
|
util.spawn(theme.wallpaper_cmd[util.cycle(#theme.wallpaper_cmd, s)], false, s)
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
end
|
2009-04-28 19:40:14 +02:00
|
|
|
if theme.font then capi.awesome.font = theme.font end
|
|
|
|
if theme.fg_normal then capi.awesome.fg = theme.fg_normal end
|
|
|
|
if theme.bg_normal then capi.awesome.bg = theme.bg_normal end
|
|
|
|
else
|
|
|
|
return print("E: error loading theme file " .. path)
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
2009-04-28 19:40:14 +02:00
|
|
|
else
|
|
|
|
return print("E: error loading theme: no path specified " )
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-11-13 11:53:41 +01:00
|
|
|
--- Get the current theme.
|
|
|
|
-- @return The current theme table.
|
|
|
|
function get()
|
2008-12-02 15:56:43 +01:00
|
|
|
return _M
|
2008-11-13 11:53:41 +01:00
|
|
|
end
|
|
|
|
|
2008-12-02 15:56:43 +01:00
|
|
|
setmetatable(_M, _M)
|
2008-08-06 15:39:51 +02:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|