Awesome: screen:count() iteration seems to break mouse.screen and others

Created on 15 Jun 2016  路  4Comments  路  Source: awesomeWM/awesome

Hi, an iteration like

for s = 1, screen:count() do
    promptbox[s] = awful.widget.prompt()
    ...
end

seems to conflict with some screen-related things, like the following call:

globalkeys = awful.util.table.join(
    awful.key({settings.modkey}, "r", function () promptbox[mouse.screen]:run() end),
    ...
)

which throws in turn the following error message:

attempt to index a nil value (field '?')

I also tried using the awful.screen.focused() method with no success.

Most helpful comment

Uhm... what's your awesome version? Try changing promptbox[mouse.screen]:run() into promptbox[mouse.screen.index]:run() if you are on git/master.

All 4 comments

Uhm... what's your awesome version? Try changing promptbox[mouse.screen]:run() into promptbox[mouse.screen.index]:run() if you are on git/master.

I just updated from master to git.
mouse.screen.index fixes this problem altogether, thank you. That being said, I am still a bit confused, as another shortcut of mine works as intended while still using the seemingly deprecated mouse.screen property:

function ()
    local screen = mouse.screen
    local tag = awful.tag.gettags(screen)[i]
        if tag then
            awful.tag.viewonly(tag)
end

There was an API changes. Instead of using numbers to refer to screens, we now use objects where possible. Thus, awful.tag.gettags expects a screen object which mouse.screen provides and everything works.

In your config you set things up using screen numbers (for s=1, screen.count() do) and thus the screen object that mouse.screen provided didn't find any entry in promptbox.

(This change was done to support dynamically adding (turning on) and removing (turning off) screens; a screen number would change its meaning across such a screen (it could now refer to a different screen) and thus objects need to be used; the default config was changed to make this actually work and it likely won't work with your current config.)

Closing this since apparently there is nothing left to solve.

Alright, thanks for the heads up.

Was this page helpful?
0 / 5 - 0 ratings