Hi again,

On 30.10.2013 18:42, Andre Klärner wrote:
> On Wed 30.10.2013 18:00:33, Uli Schlachter wrote:
>> On 30.10.2013 03:37, Andre Klärner wrote:
>>> as my setup at home is a bit more complex than the one on the go and at
>>> work I had to modify the xrandr screen table function a bit. To not keep it
>>> just for me I updated the wiki page for it.
>>>
>>> https://awesome.naquadah.org/wiki/XRandR_Screen_Table
>>>
>>> I'd be grateful if anyone using the script might try out the updated
>>> version and tell me if and what mistakes I made.
>>
>> I might be missing something, but I think that this code (copied from that 
>> wiki
>> page):
>>
>>  screens = xrandr_screens()
>>  client.focus.screen = screens["VGA"]
>>
>> is equivalent to this code:
>>
>>  client.focus.screen = screen.VGA.index
> 
> This doesn't work for me. I tried with v3.4.15 and it first struggeled with
> the output name "DP-1", and on my laptop with an output named "LVDS" it
> also returned nothing at all.

For DP-1, you would need screen["DP-1"].index. In lua, foo.bar is syntactic
sugar for foo["bar"], but the later is more generic and also works with
non-lua-identifiers.

I tested this for all my screens locally with:

$ echo 'return screen.LVDS1.index' | awesome-client
   double 2
$ echo 'return screen.VGA1.index' | awesome-client
   double 1


Having written this mail and re-reading it before sending it, I notice that you
mentioned awesome 3.4.15. A quick look confirms that 3.4 does not have this
feature. It was introduced in the following commit:

commit 9393b2d1110b308edddf3255b5a001fe64f49478
Author: Julien Danjou <[email protected]>
Date:   Mon Sep 21 20:35:14 2009 +0200

    screen: add index by output name (FS#361)

    Signed-off-by: Julien Danjou <[email protected]>

> I tried to find the code responsible for creating the screens array, but it
> seems like I am not a really good C-reader. But if such a feature was
> available it would definately ease my day.

Heh. :-)

Look at screen.c, function luaA_screen_module_index(). This function is called
whenever you index the screen object. It's implementation is:

/** Screen module.
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lfield number The screen number, to get a screen.
 */
static int
luaA_screen_module_index(lua_State *L)
{
    const char *name;

    if((name = lua_tostring(L, 2)))
        foreach(screen, globalconf.screens)
            foreach(output, screen->outputs)
                if(A_STREQ(output->name, name))
                    return luaA_pushscreen(L, screen);

    int screen = luaL_checknumber(L, 2) - 1;
    luaA_checkscreen(screen);
    return luaA_pushscreen(L, &globalconf.screens.tab[screen]);
}

So it checks all screens and for each of its output, it checks its name (a
screen can have more than one output! A screen object tells you about its output
with the "outputs" key. This is a table with the keys being the output name and
the values being another table with entries "mm_width" and "mm_height")

Uli
-- 
Bruce Schneier can read and understand Perl programs.

-- 
To unsubscribe, send mail to [email protected].

Reply via email to