vicious: load widget modules only when needed

There's no more need to edit init files and manually disable widgets.

Signed-off-by: Joerg T. (Mic92) <jthalheim@gmail.com>
Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
This commit is contained in:
Joerg T. (Mic92) 2011-05-10 00:47:58 +02:00 committed by Adrian C. (anrxc)
parent 06e8f7c68a
commit dcc2b60cd8
4 changed files with 26 additions and 43 deletions

6
README
View File

@ -29,9 +29,9 @@ $XDG_CONFIG_HOME (usually ~/.config):
$ mv vicious $XDG_CONFIG_HOME/awesome/ $ mv vicious $XDG_CONFIG_HOME/awesome/
If you want you can disable widgets you will not use, to avoid having Vicious will only load modules for widget types you intend to use in
useless modules sitting in your memory. You can comment out any widget your awesome configuration, to avoid having useless modules sitting in
type from the "Configure widgets" list in the widgets/init.lua file. your memory.
Then add the following to the top of your rc.lua: Then add the following to the top of your rc.lua:

View File

@ -5,20 +5,13 @@
-- * (c) 2010, Adrian C. <anrxc@sysphere.org> -- * (c) 2010, Adrian C. <anrxc@sysphere.org>
--------------------------------------------------- ---------------------------------------------------
-- {{{ Configure widgets -- {{{ Setup environment
require("vicious.contrib.batacpi") local setmetatable = setmetatable
require("vicious.contrib.batpmu") local wrequire = require("vicious.helpers").wrequire
require("vicious.contrib.batproc")
require("vicious.contrib.dio")
require("vicious.contrib.mpc")
require("vicious.contrib.netcfg")
require("vicious.contrib.net")
require("vicious.contrib.ossvol")
require("vicious.contrib.pop")
require("vicious.contrib.pulse")
require("vicious.contrib.rss")
require("vicious.contrib.sensors")
-- }}}
-- Vicious: widgets for the awesome window manager -- Vicious: widgets for the awesome window manager
module("vicious.contrib") module("vicious.contrib")
-- }}}
-- Load modules at runtime as needed
setmetatable(_M, { __index = wrequire })

View File

@ -9,6 +9,8 @@
-- {{{ Grab environment -- {{{ Grab environment
local pairs = pairs local pairs = pairs
local rawget = rawget
local require = require
local tonumber = tonumber local tonumber = tonumber
local io = { open = io.open } local io = { open = io.open }
local setmetatable = setmetatable local setmetatable = setmetatable
@ -29,6 +31,13 @@ local scroller = {}
-- }}} -- }}}
-- {{{ Helper functions -- {{{ Helper functions
-- {{{ Loader of vicious modules
function wrequire(table, key)
local module = rawget(table, key)
return module or require(table._NAME .. "." .. key)
end
-- }}}
-- {{{ Expose path as a Lua table -- {{{ Expose path as a Lua table
function pathtotable(dir) function pathtotable(dir)
return setmetatable({ _path = dir }, return setmetatable({ _path = dir },

View File

@ -5,32 +5,13 @@
-- * (c) 2010, Adrian C. <anrxc@sysphere.org> -- * (c) 2010, Adrian C. <anrxc@sysphere.org>
--------------------------------------------------- ---------------------------------------------------
-- {{{ Configure widgets -- {{{ Setup environment
require("vicious.widgets.cpu") local setmetatable = setmetatable
require("vicious.widgets.cpuinf") local wrequire = require("vicious.helpers").wrequire
require("vicious.widgets.cpufreq")
require("vicious.widgets.thermal")
require("vicious.widgets.uptime")
require("vicious.widgets.bat")
require("vicious.widgets.mem")
require("vicious.widgets.os")
require("vicious.widgets.fs")
require("vicious.widgets.dio")
require("vicious.widgets.raid")
require("vicious.widgets.hddtemp")
require("vicious.widgets.net")
require("vicious.widgets.wifi")
require("vicious.widgets.mbox")
require("vicious.widgets.mboxc")
require("vicious.widgets.mdir")
require("vicious.widgets.gmail")
require("vicious.widgets.org")
require("vicious.widgets.pkg")
require("vicious.widgets.mpd")
require("vicious.widgets.volume")
require("vicious.widgets.weather")
require("vicious.widgets.date")
-- }}}
-- Vicious: widgets for the awesome window manager -- Vicious: widgets for the awesome window manager
module("vicious.widgets") module("vicious.widgets")
-- }}}
-- Load modules at runtime as needed
setmetatable(_M, { __index = wrequire })