Fix various instances of global variables

The modules awful.menu and awful.util were placing variables in the global
environment which is a bad thing. Fix this by adding the right module name
prefixes to these variables.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-11-30 22:46:55 +01:00
parent e24c09e828
commit 4c094a279d
2 changed files with 9 additions and 9 deletions

View File

@ -56,7 +56,7 @@ end
-- key to up action. This is common to all created menu.
-- @class table
-- @name menu_keys
menu_keys = { up = { "Up" },
menu.menu_keys = { up = { "Up" },
down = { "Down" },
back = { "Left" },
exec = { "Return" },
@ -196,19 +196,19 @@ local function grabber(_menu, mod, key, event)
if event ~= "press" then return end
local sel = _menu.sel or 0
if util.table.hasitem(menu_keys.up, key) then
if util.table.hasitem(menu.menu_keys.up, key) then
local sel_new = sel-1 < 1 and #_menu.items or sel-1
_menu:item_enter(sel_new)
elseif util.table.hasitem(menu_keys.down, key) then
elseif util.table.hasitem(menu.menu_keys.down, key) then
local sel_new = sel+1 > #_menu.items and 1 or sel+1
_menu:item_enter(sel_new)
elseif sel > 0 and util.table.hasitem(menu_keys.enter, key) then
elseif sel > 0 and util.table.hasitem(menu.menu_keys.enter, key) then
_menu:exec(sel)
elseif sel > 0 and util.table.hasitem(menu_keys.exec, key) then
elseif sel > 0 and util.table.hasitem(menu.menu_keys.exec, key) then
_menu:exec(sel, { exec = true })
elseif util.table.hasitem(menu_keys.back, key) then
elseif util.table.hasitem(menu.menu_keys.back, key) then
_menu:hide()
elseif util.table.hasitem(menu_keys.close, key) then
elseif util.table.hasitem(menu.menu_keys.close, key) then
menu.get_root(_menu):hide()
else
check_access_key(_menu, key)

View File

@ -28,7 +28,7 @@ local capi =
local util = {}
util.table = {}
shell = os.getenv("SHELL") or "/bin/sh"
util.shell = os.getenv("SHELL") or "/bin/sh"
function util.deprecate(see)
io.stderr:write("W: awful: function is deprecated")
@ -84,7 +84,7 @@ end
-- @param screen The screen where to run the command.
function util.spawn_with_shell(cmd, screen)
if cmd and cmd ~= "" then
cmd = shell .. " -c \"" .. cmd .. "\""
cmd = util.shell .. " -c \"" .. cmd .. "\""
return capi.awesome.spawn(cmd, false, screen or capi.mouse.screen)
end
end