Beatiful module ported to lua 5.2

Tested on Lua 5.1: all good

Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
This commit is contained in:
Arvydas Sidorenko 2012-06-12 03:24:22 +02:00 committed by Uli Schlachter
parent 9623b8e42f
commit 0bbd9eac0a
2 changed files with 11 additions and 7 deletions

View File

@ -5,7 +5,7 @@ require("awful.rules")
-- Widget and layout library -- Widget and layout library
require("wibox") require("wibox")
-- Theme handling library -- Theme handling library
require("beautiful") local beautiful = require("beautiful")
-- Notification library -- Notification library
require("naughty") require("naughty")
require("menubar") require("menubar")

View File

@ -25,7 +25,7 @@ local capi =
} }
--- Theme library. --- Theme library.
module("beautiful") local beautiful = { mt = {} }
-- Local data -- Local data
local theme local theme
@ -59,17 +59,17 @@ local function set_font(name)
active_font = load_font(name).name active_font = load_font(name).name
end end
function get_font(name) function beautiful.get_font(name)
return load_font(name).description return load_font(name).description
end end
function get_font_height(name) function beautiful.get_font_height(name)
return load_font(name).height return load_font(name).height
end end
--- Init function, should be runned at the beginning of configuration file. --- Init function, should be runned at the beginning of configuration file.
-- @param path The theme file path. -- @param path The theme file path.
function init(path) function beautiful.init(path)
if path then if path then
local success local success
success, theme = pcall(function() return dofile(path) end) success, theme = pcall(function() return dofile(path) end)
@ -105,13 +105,17 @@ end
--- Get the current theme. --- Get the current theme.
-- @return The current theme table. -- @return The current theme table.
function get() function beautiful.get()
return theme return theme
end end
function beautiful.mt:__index(k)
return theme[k]
end
-- Set the default font -- Set the default font
set_font("sans 8") set_font("sans 8")
setmetatable(_M, { __index = function(t, k) return theme[k] end }) return setmetatable(beautiful, beautiful.mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80