From 1a7b43068c4cfbb7baa3f781fb7d65a708f63a5c Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 25 Jun 2012 00:15:51 +0200 Subject: [PATCH 1/3] contrib: initialization bugfix after lua52 port The _NAME field was missing in the contrib table. Thanks to Jorg Thalheim for reporting this. --- contrib/init.lua | 2 +- helpers.lua | 4 ++-- init.lua | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) 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/helpers.lua b/helpers.lua index 93a701b..4c15690 100644 --- a/helpers.lua +++ b/helpers.lua @@ -33,8 +33,8 @@ 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 -- }}} diff --git a/init.lua b/init.lua index fa57ea7..275799a 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ 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 = {} From e1c7c4772a8c1c651964bbcfbcdc0dc5d47d6dc4 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 25 Jun 2012 00:39:23 +0200 Subject: [PATCH 2/3] os: change os.getenv init to allow standalone usage of os widget Test case: lua> foo = require("vicious.widgets.os") lua> print(foo()[1]) /usr/share/lua/5.1/vicious/widgets/os.lua:66: attempt to call field 'getenv' (a nil value) --- widgets/os.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"]} From 3b161ffa28e50d6674e081a2ee28c76b05d8b014 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 25 Jun 2012 01:22:53 +0200 Subject: [PATCH 3/3] contrib: document how to enable contributed widgets --- README | 3 ++- contrib/README | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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 16716ac..0c1e55b 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