diff --git a/README b/README index d0f52b8..6cae001 100644 --- a/README +++ b/README @@ -291,7 +291,8 @@ in the contrib directory of Vicious. The contrib directory contains extra widgets you can use. Some are for less common hardware, and other were contributed by Vicious users. The contrib directory also holds widget types that were obsoleted or rewritten. Contrib widgets -will not be imported by init unless you explicitly enable it. +will not be imported by init unless you explicitly enable it, or load +them in your rc.lua. Richard Kolkovich, a FreeBSD user, published his vicious-fbsd branch. If you are also a BSD user you can find his work here: diff --git a/contrib/README b/contrib/README index b093b08..cc2e5c9 100644 --- a/contrib/README +++ b/contrib/README @@ -4,7 +4,17 @@ Contrib widgets are extra widgets you can use. Some are for less common hardware, and other were contributed by Vicious users. The contrib directory also holds widget types that were obsoleted or rewritten. Contrib widgets will not be imported by init unless you -explicitly enable it. +explicitly enable it, or load them in your rc.lua. + + +Usage +----- +To use contrib widgets uncomment the line that loads them in +init.lua. Or you can load them in your rc.lua after you require +Vicious: + + local vicious = require("vicious") + vicious.contrib = require("vicious.contrib") Widget types diff --git a/contrib/ac.lua b/contrib/ac.lua index f3911fa..48d1961 100644 --- a/contrib/ac.lua +++ b/contrib/ac.lua @@ -32,4 +32,4 @@ end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(_M, { __call = function(_, ...) return worker(...) end }) diff --git a/contrib/init.lua b/contrib/init.lua index d30b33d..4328aae 100644 --- a/contrib/init.lua +++ b/contrib/init.lua @@ -11,7 +11,7 @@ local wrequire = require("vicious.helpers").wrequire -- Vicious: widgets for the awesome window manager -- vicious.contrib -local contrib = {} +local contrib = { _NAME = "vicious.contrib" } -- }}} -- Load modules at runtime as needed diff --git a/contrib/wpa.lua b/contrib/wpa.lua index 3b6fa21..f42e852 100644 --- a/contrib/wpa.lua +++ b/contrib/wpa.lua @@ -62,6 +62,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) - - +return setmetatable(_M, { __call = function(_, ...) return worker(...) end }) diff --git a/helpers.lua b/helpers.lua index 93a701b..7c01cf6 100644 --- a/helpers.lua +++ b/helpers.lua @@ -33,11 +33,10 @@ local scroller = {} -- {{{ Helper functions -- {{{ Loader of vicious modules -function helpers.wrequire(table, key) - local module = rawget(table, key) +function helpers.wrequire(table, key) + local module = rawget(table, key) return module or require(table._NAME .. "." .. key) end --- }}} -- {{{ Expose path as a Lua table function helpers.pathtotable(dir) diff --git a/init.lua b/init.lua index fa57ea7..e7b1457 100644 --- a/init.lua +++ b/init.lua @@ -16,12 +16,12 @@ local table = { insert = table.insert, remove = table.remove } - local helpers = require("vicious.helpers") -- Vicious: widgets for the awesome window manager local vicious = {} vicious.widgets = require("vicious.widgets") +--vicious.contrib = require("vicious.contrib") -- Initialize tables local timers = {} diff --git a/widgets/init.lua b/widgets/init.lua index 4625df0..5d3b246 100644 --- a/widgets/init.lua +++ b/widgets/init.lua @@ -1,18 +1,5 @@ ---------------------------------------------------- --- Vicious widgets for the awesome window manager ---------------------------------------------------- --- Licensed under the GNU General Public License v2 --- * (c) 2010, Adrian C. ---------------------------------------------------- --- {{{ Setup environment -local setmetatable = setmetatable local wrequire = require("vicious.helpers").wrequire +widgets = { _NAME = "vicious.widgets" } --- Vicious: widgets for the awesome window manager --- vicious.widgets -local widgets = { _NAME = "vicious.widgets" } --- }}} - --- Load modules at runtime as needed -return setmetatable(widgets, { __index = wrequire }) +return setmetatable(widgets, {__index = wrequire}) diff --git a/widgets/os.lua b/widgets/os.lua index 288fcd4..52180e3 100644 --- a/widgets/os.lua +++ b/widgets/os.lua @@ -7,8 +7,8 @@ local pairs = pairs local tonumber = tonumber local io = { popen = io.popen } -local os = { getenv = os.getenv } local math = { ceil = math.ceil } +local los = { getenv = os.getenv } local setmetatable = setmetatable local helpers = require("vicious.helpers") local string = { @@ -63,7 +63,7 @@ local function worker(format) end -- Get user from the environment - system["username"] = os.getenv("USER") + system["username"] = los.getenv("USER") return {system["ostype"], system["osrelease"], system["username"], system["hostname"], system["entropy"], system["entropy_p"]} diff --git a/widgets/uptime.lua b/widgets/uptime.lua index 14de99a..7d5eca2 100644 --- a/widgets/uptime.lua +++ b/widgets/uptime.lua @@ -33,4 +33,5 @@ local function worker(format) end -- }}} -local setmetatable(uptime, { __call = function(_, ...) return worker(...) end }) +setmetatable(uptime, { __call = function(_, ...) return worker(...) end }) +return uptime