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-08-21 21:26:50 +02:00
|
|
|
local pcall = pcall
|
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
|
|
|
|
2009-04-28 22:54:55 +02:00
|
|
|
--- Theme library.
|
2008-08-08 19:07:42 +02:00
|
|
|
module("beautiful")
|
2008-08-05 22:21:22 +02:00
|
|
|
|
|
|
|
-- Local data
|
2009-08-21 21:26:50 +02:00
|
|
|
local theme
|
2008-08-05 22:21:22 +02:00
|
|
|
|
|
|
|
--- Init function, should be runned at the beginning of configuration file.
|
|
|
|
-- @param path The theme file path.
|
|
|
|
function init(path)
|
|
|
|
if path then
|
2009-08-21 21:26:50 +02:00
|
|
|
local success
|
|
|
|
success, theme = pcall(function() return dofile(path) end)
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2009-08-21 21:26:50 +02:00
|
|
|
if not success then
|
|
|
|
return print("E: beautiful: error loading theme file " .. theme)
|
|
|
|
elseif theme then
|
2009-04-28 19:40:14 +02:00
|
|
|
-- 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
|
2009-08-21 21:26:50 +02:00
|
|
|
return print("E: beautiful: error loading theme file " .. path)
|
2008-08-05 22:21:22 +02:00
|
|
|
end
|
2009-04-28 19:40:14 +02:00
|
|
|
else
|
2009-08-21 21:26:50 +02:00
|
|
|
return print("E: beautiful: 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()
|
2009-04-28 22:54:55 +02:00
|
|
|
return theme
|
2008-11-13 11:53:41 +01:00
|
|
|
end
|
|
|
|
|
2009-04-28 22:54:55 +02:00
|
|
|
setmetatable(_M, { __index = function(t, k) return theme[k] end })
|
2008-08-06 15:39:51 +02:00
|
|
|
|
2009-08-21 15:54:14 +02:00
|
|
|
-- Init with default theme.
|
|
|
|
init("@AWESOME_THEMES_PATH@/default/theme.lua")
|
|
|
|
|
2008-08-06 15:39:51 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|