On Mon, Oct 3, 2011 at 11:56 PM, Oon-Ee Ng <[email protected]> wrote:
> Anyone has experience using awesome mouse-only (since that's the most
> reliable method over VNC from a phone with no physical keyboard)?
>
> In particular, is it possible to have a small widget of some sort in
> the taglist for each window (just for closing the window, as it seems
> a pity to have to enable title-bars just to do this)?

i like menus attached to taglist and tasklist for mouse manipulation.
With these menus, and their helper functions, you can do pretty much
anything with tags or client.

-- for the taglist
function menu_taglist(menu, t)
    if not menu then
        menu = {}
    end
    num_screens = screen.count()
    next_screen = nil
    prev_screen = nil

    menu.items = {}
    menu.items = {
        {(t.selected and "Hide") or "Merge", function()
            t.selected = not t.selected end},
        {"Rename", function() shifty.rename(t) end},
        {"Restore", function() tag_restore_defaults(t) end},
        {"Delete", function() shifty.del(t) end},
    }

    if num_screens > 1 then
        -- decide to show 'move next' only or also prev screen
        next_screen = awful.util.cycle(num_screens, t.screen + 1)
        table.insert(menu.items, 2, {"Move to screen " .. next_screen,
                function() tag_to_screen(t, next_screen) end})

        if num_screens > 2 then
            prev_screen = awful.util.cycle(num_screens, t.screen + 1)
            table.insert(menu.items, 3, {"Move to screen " .. prev_screen,
                    function() tag_to_screen(t, prev_screen) end})
        end
    end

    local m = awful.menu.new(menu)
    m:show()
    return m
end

widgets.taglist = {}
widgets.taglist.buttons = awful.util.table.join(
        awful.button({}, 1, awful.tag.viewonly),
        awful.button({settings.modkey}, 1, awful.client.movetotag),
        awful.button({}, 2, awful.tag.viewtoggle),
        awful.button({settings.modkey}, 3, awful.client.toggletag),
        awful.button({}, 3, function(t)
            if instance then instance:hide(); instance = nil
            else instance = menu_taglist({width = 165}, t) end
        end),
        awful.button({}, 4, awful.tag.viewnext),
        awful.button({}, 5, awful.tag.viewprev)
    )

-- and for clients
function menu_clients(menu, c)
    -- list of other clients
    local cls = client.get()
    local cls_t = {}
    for k, clnt in pairs(cls) do
        cls_t[#cls_t + 1] = {ctitle(clnt),
            function()
                if not clnt:isvisible() then
                    awful.tag.viewmore(clnt:tags(), clnt.screen)
                end
                client.focus = clnt
            end,
            clnt.icon}
    end

    -- list of tags can send to
    tgs_m = {}
    for s = 1, screen.count() do
        skey = 'Screen '..s

        local tgs_t = {}
        for i, t in ipairs(screen[s]:tags()) do
            tgs_t[i] = {awful.util.escape(t.name) or "",
                                function()
                                    c:tags({t})
                                    c.screen = t.screen
                                end
                            }
        end
        table.insert(tgs_t, #tgs_t + 1, {"New tag", function()
            new_tag_name = (c.instance and c.instance:gsub("%s.+$", "")) or nil
            t = shifty.add({name = new_tag_name, screen = s})
            awful.client.movetotag(t, c)
            awful.tag.viewonly(t)
            client.focus = c
            c:raise()

        end})

        tgs_m[s] = {skey .. "  ►", tgs_t}
    end

    if not menu then
        menu = {}
    end

    menu.items = {
        {"⬛⬛⬛ " .. ctitle(c) .. " ⬛⬛⬛", function() end},
        {"✖ Close", function() c:kill() end},
        {(client_is_maximized(c) and "ⴿ  Restore") or "ⴽ  Maximize",
         function()
             toggle_maximized(c)
         end},
        {(c.minimized and "⇱  Restore") or "⇲  Minimize", function()
            c.minimized = not c.minimized
        end},
        {(c.sticky and "⚫  Un-Stick") or "⚪  Stick", function()
            c.sticky = not c.sticky
        end},
        {(c.ontop and "⤼  Offtop") or "⤽  Ontop", function()
            c.ontop = not c.ontop
            if c.ontop then c:raise() end
        end},
        {((awful.client.floating.get(c) and "▦  Tile") or "☁  Float"),
         function() float_toggle(c) end},
        {"Move to tag  ►", tgs_m},
        {"Clients      ►", cls_t}
    }
    local m = awful.menu.new(menu)
    m:show()
    return m
end

-- Tasklist
widgets.tasklist = {}
widgets.tasklist.buttons = awful.util.table.join(
    awful.button({}, 1, focus_min_or_restore),
    awful.button({}, 3, function(c)
        if instance then instance:hide(); instance = nil
        else instance = menu_clients({width = 165}, c) end
    end),
    awful.button({}, 4, function()
        awful.client.focus.byidx(1)
        if client.focus then client.focus:raise() end
    end),
    awful.button({}, 5, function()
        awful.client.focus.byidx(-1)
        if client.focus then client.focus:raise() end
    end))

yeah, thats a lot of code for an e-mail body. i'm being lazy.

you can find the whole code (helper functions included) here:
ttps://github.com/bioe007/awesome-configs/blob/89220d53368970a9530cb7733575d970914c77b4/widgets.lua

-- 
perry

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

Reply via email to