Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using awesomewm and have two monitors, so Mod4+j and Mod4+k cycle through windows on current screen only. Is there a way to cycle through all windows/clients on all screens to make it work like ordinary Alt+Tab?

share|improve this question
add comment

2 Answers

Of course it is!

The key-bindings in awesome are controled by the rc file, which is actually a lua script. The key bindings are just that, they bind keys to lua functions. You are free to make the functions do whatever you want them to do.

In your case, you want to bind those keys to a function that changes the active tag on each screen rather than just the currently focus screen.

Right now you probably have a couple of lines similar to this in your config:

awful.key({ modkey }, "j", awful.tag.viewprev )

...which does just about what it looks like.

What you are going to want to do is change these from simple command calls to the awesome API to be little functions that run a couple of commands in sequence. The awful.tag.viewprev() and aweful.tag.viewnext() functions conveniently take an optional argument of what screen to operate on. By default they work on the current one, but you can over-ride this.

For example, to run the same thing on both screens 1 and 2, the above line might be changed to this:

awful.key({ modkey }, "j", function () awful.tag.viewprev(1); awful.tag.viewprev(2) end)

Keep in mind your context might be a little different. Be sure and watch where various structures like parens, braces, etc are opened and closed and to end lines that are part of lists with a comma. Adapt as necessary to match your config file.

share|improve this answer
    
Thank you for your answer, Caleb, but unfortunately it does not work. It throws a syntax error. Also, awful.tag.viewprev() works with tags, and I need to cycle through clients. For this to work I would have to open one client per tag only. Furthermore these calls for each screen would first focus previous tag on screen 1 and then focus previous tag on screen 2(i guess). –  Sergey Eremin Oct 24 '12 at 16:19
add comment

After poking around awful module docs i found a solution. It is hacky, but it works as I wanted it to work.

awful.key({ modkey,           }, "Tab",
    function ()
        awful.client.focus.byidx(1)
        if awful.client.ismarked() then
            awful.screen.focus_relative(-1)
            awful.client.getmarked()
        end
        if client.focus then
            client.focus:raise()
        end
        awful.client.togglemarked()
    end),

This function cycles through clients on current screen, marking them and when they all are marked, jumps to the next screen. Here is what happens step by step:

It is funny because i do not know what "marked" means. Marked clients do not seem to differ from not marked clients visually or by behaviour.

It is strange that i had to write a 10 line function to get something as trivial as multiscreen alt-tab. I might have done something excessive)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.