From 0bbd9eac0a1478441d97ff5f278d1954d8dfc6fe Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Tue, 12 Jun 2012 03:24:22 +0200 Subject: [PATCH] Beatiful module ported to lua 5.2 Tested on Lua 5.1: all good Signed-off-by: Arvydas Sidorenko --- awesomerc.lua.in | 2 +- lib/beautiful.lua.in | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index db1f0742..30ee580f 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -5,7 +5,7 @@ require("awful.rules") -- Widget and layout library require("wibox") -- Theme handling library -require("beautiful") +local beautiful = require("beautiful") -- Notification library require("naughty") require("menubar") diff --git a/lib/beautiful.lua.in b/lib/beautiful.lua.in index cf512fd1..88eb9705 100644 --- a/lib/beautiful.lua.in +++ b/lib/beautiful.lua.in @@ -25,7 +25,7 @@ local capi = } --- Theme library. -module("beautiful") +local beautiful = { mt = {} } -- Local data local theme @@ -59,17 +59,17 @@ local function set_font(name) active_font = load_font(name).name end -function get_font(name) +function beautiful.get_font(name) return load_font(name).description end -function get_font_height(name) +function beautiful.get_font_height(name) return load_font(name).height end --- Init function, should be runned at the beginning of configuration file. -- @param path The theme file path. -function init(path) +function beautiful.init(path) if path then local success success, theme = pcall(function() return dofile(path) end) @@ -105,13 +105,17 @@ end --- Get the current theme. -- @return The current theme table. -function get() +function beautiful.get() return theme end +function beautiful.mt:__index(k) + return theme[k] +end + -- Set the default font 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