On Tue, Oct 20, 2009 at 06:29:50PM -0200, Emmanuel Oga wrote:
> 
> * Whenever I need to find a specific window, I need to modkey-1.to.9
> to find it. I know there is a window list if I click with the mouse,
> but using he mouse is suboptimal. Ideally I would like to have
> something like vim's fuzzyfilefinder but for awesome client
> names/classes.

With that I can help you a little.
At first, let me explain what the following code do from user's point of view.

I use Mod4+` (Win+apostrophe) to select tag by name,
i.e. I press Mod4+`, type «w» and goto to the first tag with letter «w»
in its name (in my case it's «www»).

I use Mod4+Shift+` to select ALL tags with given string in their names
in the same way.

I use Mod4+/ to select client by name (client's name, class & instance
is searched case insensitive, but you can change it by hacking following code).
E.g. I press Mod4+slash and type "firefox" to goto to tag «www» and focus
Firefox window.

I use Mod4+Shift+/ to move ALL clients with given string in the name
into the currently selected tag (or tags), something like «hey, clients <name>,
gather here =)

Here're two helper functions:

function find_tags(name)
    if not name or name == "" then return end

    local tags = screen[mouse.screen]:tags()
    local found_tags = {}
    if tags and #tags > 0 then
        for i, tag in ipairs(tags) do
            if tag.name:find(name) then
                table.insert(found_tags, tag)
            end
        end
        if #found_tags > 0 then return found_tags end
    end
end

function find_clients(name)
    if not name or name == "" then return end

    local clients = client.get(mouse.screen)
    local found_clis = {}
    if clients and #clients > 1 then
        for i, cli in ipairs(clients) do
            if cli.name:lower():find(name)
                or cli.class:lower():find(name)
                or cli.instance:lower():find(name) then
                table.insert(found_clis, cli)
            end
        end
        if #found_clis > 0 then return found_clis end
    end
end

I use them in my rc.lua in the following way:

>>> this code goes to globalkeys table <<<
awful.key({ modkey }, "apostrophe", function ()
    awful.prompt.run({ prompt = "Tag name: " },
    mypromptbox[mouse.screen].widget,
    function (name)
        local tags = find_tags(name)
        if tags then
            awful.tag.viewonly(tags[1])
        end
    end, nil, nil)
end),

awful.key({ modkey, "Shift" }, "apostrophe", function ()
    awful.prompt.run({ prompt = "Tags name: " },
    mypromptbox[mouse.screen].widget,
    function (name)
        local tags = find_tags(name)
        if tags then
            awful.tag.viewmore(tags)
        end
    end, nil, nil)
end),

awful.key({ modkey }, "slash", function ()
    awful.prompt.run({ prompt = "Client name: " },
    mypromptbox[mouse.screen].widget,
    function (name)
        local clis = find_clients(name)
        if clis then
            awful.tag.viewonly(clis[1]:tags()[1])
            client.focus = clis[1]
        end
    end, nil, nil)
end),

awful.key({ modkey, "Shift" }, "slash", function ()
    awful.prompt.run({ prompt = "Clients name: " },
    mypromptbox[mouse.screen].widget,
    function (name)
        local clis = find_clients(name)
        if clis then
            local current_tags = {}
            local tags = screen[mouse.screen]:tags()
            for i, tag in ipairs(tags) do
                if tag.selected then table.insert(current_tags, tag) end
            end

            for i, cli in ipairs(clis) do
                cli:tags(current_tags)
            end
        end
    end, nil, nil)
end),
>>> end of code <<<

> * I can't find an easy way of renaming tags. Is it at all possible
> without using something like Shifty? (The reason I don't want to use
> Shifty *yet* is there has to be an easier way of doing that with plain
> old AWM, right?)

You can definitely write some function to do it, yes.
You can, e.g. look into shifty for code to do it.

> * Is there any way of persisting the layout/cleints without having to
> script that "manually" ? Example, in wmii you can persist your layout,
> so if you want to have one screen with say,. one vim at the right, one
> firefox to the left, you can do it using the command line.

Again, shifty can do it. E.g. I have my mail client in master column
on tag «mail», and pidgin in stack col on the same tag.

> BTW; yes, I read the man page and browsed the wiki, if you think I
> missed something please, could you provide a link to the info about
> it? Thanks in advance!

Well, actually two last question are quite easy sovable by using shifty.
You shouldn't afraid of it, it's really easy, espessially if you read
docs on it.

As for 1st question, I hope my example can be helpful here.

Good luck with awesome!
May it bring awesomeness in your life =)

===
Konstantin Stepanov

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

Reply via email to