I'm having trouble understanding the following. I have the following code:
awful.key({ "Mod1" }, "Tab",
function (c)
local grabber = awful.keygrabber.run(
function(mod, key, event)
if grabber == nil then
naughty.notify({ text="nope"})
end
awful.keygrabber.stop(grabber)
return
end)
end)
This is supposed to grab the keyboard when I press super+Tab then release keyboard focus by calling the stop method. However the grabber
variable appears to be nil
. At first I thought this was a scope problem, so I removed the local
, this works. However I have the feeling as if this isn't the way to solve this problem.
After messing around with it I found out this works:
awful.key({ "Mod1" }, "Tab",
function (c)
local grabber
grabber = awful.keygrabber.run(
function(mod, key, event)
if grabber == nil then
naughty.notify({ text="nope"})
end
awful.keygrabber.stop(grabber)
return
end)
end)
The only difference is that the variable grabber
is defined on one line and is assigned one line later. Why can't I do this on the same line?